public class AcitivyLanchMM extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Button btn = new Button(this);
btn.setText("Lanch");
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
startActivity(AcitivyLanchMM.this.getPackageManager().getLaunchIntentForPackage("com.tencent.mm"));
//Lanch();
}
});
setContentView(btn);
}
void Lanch() {
Intent intent = new Intent();
ComponentName cmp = new ComponentName("com.tencent.mm ", "com.tencent.mm.ui.LauncherUI");
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(cmp);
startActivity(intent);
//startActivityForResult(intent, 0);
}
}
网友评论