How to maintain context switching between two activity?

Hi Priyank,

I tried this with android activity manager and it worked for me.

  1. Use apktool to extract contents of apk with command java -jar d -f aut.apk
  2. locate AndroidManifest.xml file.
  3. The AndroidManifest.xml file can be opened in any text editor. I recommend one with syntax highlighting.
  4. Search for the Keyword “LAUNCHER” and note down the activity name associated with it.This activity should be started when the user taps the application icon in the Launcher (handles specific intent Category called LAUNCHER).

Something like

<activity android:name="your.app.package.name.MainActivityName">
  <intent-filter>
   <action android:name="android.intent.action.MAIN" />
   <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity> 

Now run command adb shell am start your.app.package.name/.MainActivityName which will display something like this

 Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=your.app.package.name/.MainActivity } in std o/p .

Note : Please separate package name and main activity name in command with a forward slash followed by dot.

If you see a warning message like “Warning: Activity not started, its current task has been brought to the front” that means you have done it- congratulations :smile: .

In addition with this people can run adb shell am start -a android.intent.action.MAIN -c android.intent.category.HOME to send the app in backgroud(many people asked this question before)