Aug 13, 2011

Start a specified app

If you want to start another app directly, you can use the code intent.setClassName(PACKAGE_NAME, CLASS_NAME) to specify the expected app.
- PACKAGE_NAME is the name of the package.
- CLASS_NAME is the name of the class inside the package.

For example, we have another installed app in package "com.test.AndroidSlave", we can start the activity "com.test.AndroidSlave.AndroidSlaveActivity" inside the package.

Start a specified app

package com.test.AndroidMaster;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class AndroidMasterActivity extends Activity {

final static String PACKAGE_NAME = "com.test.AndroidSlave";
final static String CLASS_NAME = "com.test.AndroidSlave.AndroidSlaveActivity";

Button btnStartSlave;

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
btnStartSlave = (Button)findViewById(;
btnStartSlave.setOnClickListener(new Button.OnClickListener(){

public void onClick(View arg0) {
// TODO Auto-generated method stub

private void startSlave(){
Intent intent = new Intent();
intent.setClassName(PACKAGE_NAME, CLASS_NAME);

Next post:
- Start a specified app with data passed
- Check if a app is instlled

1 comment:

Infolinks In Text Ads