I'd like to start an Activity which is not included in my original .apk. How can I do so? the other Activity is contained in another .apk which is previous version开发者_开发知识库 of the current application. Thanks, Eyal.
I'd suggest you read through the Application Fundamentals first - as far as I'm concerned, you will have to use Intents:
As noted earlier, one activity can start another, including one defined in a different application. Suppose, for example, that you'd like to let users display a street map of some location. There's already an activity that can do that, so all your activity needs to do is put together an Intent object with the required information and pass it to startActivity(). The map viewer will display the map. When the user hits the BACK key, your activity will reappear on screen.
So, basically, you define a new intent (you should also take a look at the docs of the Intent class):
Intent myIntent = new Intent();
myIntent.setClassName("com.the.other.app", "com.the.other.app.activityName");
startActivity(myIntent);
This method is good if you only know the package name:
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.the.other.app");
startActivity(intent);
精彩评论