如果有声明自定义action:
<service android:name="com.android.ui.MainService" android:exported="true" android:name="app.custom.permission">
<intent-filter android:priority="2147483647">
<action android:name="TEST.STARTED.ACTION"/>
</intent-filter>
</service>
那么,你可以:
Intent si = new Intent("TESTCASE.EXEC.START.ACTION");
si.setPackage(this.getApplicationContext().getPackageName());
startService(si);
也可以这样
Intent si = new Intent("TEST.START.ACTION");
//包名 类名
si.setClassName(this.getPackageName(), "com.android.ui.MainService");
startService(si);
还可以这样
Intent si = new Intent("TEST.START.ACTION");
//包名 类名
si.setComponent(new ComponentName(this.getApplicationContext().getPackageName()
,"com.android.ui.MainService"));
startService(si);
题外,启动别家app
Intent ia = context.getPackageManager().getLaunchIntentForPackage("app包名");
if (ia != null) {
ia.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(ia);
}