JEB Plugin How-To: Jump to an Activity

The API that shipped with JEB 1.3 allows direct access to the Android Manifest. Here, we are just demonstrating how some of the new methods that shipped with the API. This plugin allows a user to jump from an Activity tag in the manifest to the corresponding code in the Assembly view:

#? name=Jump to an Activity, shortcut=Ctrl+Shift+J

from jeb.api import IScript
from jeb.api.ui import View
from jeb.api.ui import CodePosition


class JumpToActivity(IScript):

  def run(self, jeb):

    # basic requirements
    ui = jeb.getUI()
    if not ui:
      return

    if jeb.getApiVersion() < 2:
      print 'Please upgrade to JEB 1.3'
      return

    ui.focusView(View.Type.MANIFEST)
    v = ui.getView(View.Type.MANIFEST)
    if not v:
      print 'No Manifest'
      return

    # whole copy of the Manifest
    text = v.getText()

    # retrieve the package name
    pname = ''
    pos = text.find('package="')
    if pos >= 0:
      pos += 9
      pos1 = text.find('"', pos)
      if pos1 >= 0:
        pname = text[pos:pos1]

    # the Activity name should be the on-caret item
    aname = v.getActiveItem()
    if not aname:
      print 'Please position the caret on the Activity name'
      return

    # absolute class classname
    if aname.startswith('.'):
      if not pname:
        print 'Package name not found'
        return
      aname = pname + aname

    ui.focusView(View.Type.ASSEMBLY)
    a = ui.getView(View.Type.ASSEMBLY)
    if not a:
      print 'No Assembly view'
      return

    # internal class name
    classname = 'L' + aname.replace('.', '/') + ';'
    if not a.setCodePosition(CodePosition(classname)):
      print 'Class not found: '+aname
      ui.focusView(View.Type.MANIFEST)

Feel free to experiment with the script, and customize it to your needs. Leave a comment if you have any questions. More sample scripts will be posted in the next week to showcase more other capabilities of API v2.

Published by

Nicolas Falliere

Author of JEB.

One thought on “JEB Plugin How-To: Jump to an Activity”

  1. May you help me please ?
    The plugin doesn’t work what can I do ?
    thanks Johan

    File “”, line 1, in
    ImportError: cannot import name jumptoanActivity

    An error occurred, the script could not be loaded

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

*