Intent.CATEGORY_LAUNCHER
因为你的程序可能有很多个activity,只要xml配置文件中有这么一个intent-filter,而且里面有这个launcher,那么这个activity就是点击程序时最先运行的那个activity。现在你只有一个activity,那么加不加就没有关系了。
示例代码:
Intent callme=new Intent(PhoneBackService.this,CallMeActivity.class);
callme.putExtra("calltime", calltime);
callme.putExtra("phonenumber", phonenumber);
callme.putExtra("iscallme", false);
callme.addCategory(Intent.CATEGORY_LAUNCHER); // 决定应用程序是否显示在程序列表里
startActivity(callme);
Intent.FLAG_ACTIVITY_NEW_TASK
在Activity上下文之外启动Activity,比如在Service中启动,需要给Intent设置FLAG_ACTIVITY_NEW_TASK标志,不然会报异常。
加了该标志,如果在同一个应用中进行Activity跳转,不会创建新的Task,只有在不同的应用中跳转才会创建新的Task。
示例代码:
Intent intent = new Intent();
ComponentName componentName = new ComponentName("cn.test.server","cn.test.server.MainActivity");
intent.setComponent(componentName);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);