Problem Calling Activity From Another Package In Android
Solution 1:
Intenti=newIntent();
i.setClassName("com.package.app1", "com.package.app2.Activity1");
startActivity(i);
Shot in the dark:
change com.package.app1
to com.package.app2
. I've called done what you're attempting right now, and I've always had to specify the package of the class I wanted to call.
Ok, PackageManager is not your solution, I misread and thought you had two apps and wanted one app to call the other. It looks like you just want one app.
Modify your app1's manifest like this:
<manifestxmlns:android="http://schemas.android.com/apk/res/android"package="com.package.app1"><applicationandroid:icon="@drawable/icon"android:debuggable="true"><activityandroid:name=".Start"android:label="@string/app_name"><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activityandroid:name="com.package.app2.Activity1" /><activityandroid:name="com.package.app2.Activity2"android:excludeFromRecents="true"></activity><activityandroid:name="com.package.app1.PlayerList" /><activityandroid:name="com.package.app1.CreateNewPlayer" /><activityandroid:name="com.package.app1.Profile" /><activityandroid:name="com.package.app1.Braintrainer" /></application><uses-permissionandroid:name="android.permission.WAKE_LOCK"></uses-permission><uses-permissionandroid:name="android.permission.VIBRATE"></uses-permission></manifest>
And try the first way again.
Solution 2:
I have several packages and need to do something similar in my app.
You need to be careful with this technique, otherwise you'll experience nasty memory leaks.
I declared my activity in my base controller (activity) class as a static variable. All controller classes inherit from this class, so all controller classes are able to access it. Pass in the activity as an argument for anything outside of the controller classes that need to access the activity.
Post a Comment for "Problem Calling Activity From Another Package In Android"