2013年7月22日星期一
Apk start another android apk from a problem caused by
I'm just learning android, now faced with this problem. From a (A) apk start another (B) apk, press the Home key to the background, and then start A, then B, is to go directly to (keep press the HOME key before, debugging found that even the A's onCreate not to) ask you heroes, how to do, no matter what time Start A when it is to the A interface?
specific code as follows:
Intent mIntent = new Intent ();
ComponentName comp = new ComponentName ("com.um.B", "com.um.B.phone.SplashScreenActivity");
mIntent.setComponent (comp);
mIntent.setAction ("android.intent.action.VIEW");
startActivity (mIntent);
PS:
I also tried this way:
PackageManager packageManager = MainActivity.this
. getPackageManager ();
Intent intent = new Intent ();
intent = packageManager.getLaunchIntentForPackage ("com.um.B");
startActivity (intent);
B apk
but because there is no icon, that is, no Main activity, so get intent is NULL
------ Solution ------------------------------------ --------
another task stack up activity
plus intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
so press the home key, and then start only its own stack A and B of Activity in another stack independently of each other
---- - For reference only ---------------------------------------
Thank you, you can because on the android do not know, after a lot of learning
订阅:
博文评论 (Atom)
没有评论:
发表评论