Android Service启动Activity .

来源:互联网 发布:二手手机交易软件 编辑:程序博客网 时间:2024/04/29 18:33
1.直接启动
Intent intent = new Intent();  
intent.setClassName("com.jinwei", "com.jinwei.A");  
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
this.startActivity(intent);  

2. Pending启动 
try {  
       getPendingIntent().send();  
   } catch (CanceledException e) {  
      // TODO Auto-generated catch block   
        e.printStackTrace();  
    }  

private PendingIntent getPendingIntent() {  
Intent callback = new Intent();  
callback.setClass(this, A.class);  
 callback.setFlags(Intent. FLAG_ACTIVITY_CLEAR_TOP);  
return PendingIntent.getActivity(this, 0, callback, PendingIntent.FLAG_CANCEL_CURRENT);  
}  
0 0
原创粉丝点击