2015-08-21 57 views
0

我使用下面的接收来自parse.com推接收器打开一个新的应用程序每次

import android.content.Context; 
import android.content.Intent; 
import com.parse.ParsePushBroadcastReceiver; 
import org.json.JSONException; 
import org.json.JSONObject; 

public class PushNotificationReceiver extends ParsePushBroadcastReceiver { 

    private String pushUrl; 

    @Override 
    public void onPushOpen(Context context, Intent intent) { 

     JSONObject json = null; 
     try { 
      json = new JSONObject(intent.getExtras().getString("com.parse.Data")); 
      pushUrl = json.getString("url").toString(); 

     } catch (JSONException e) { 
      e.printStackTrace(); 
     } 

     Intent i = new Intent(context, MainActivity.class); 
     i.putExtra("url", pushUrl); 
     i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     context.startActivity(i); 
    } 


} 

它的做工精细的推动。问题是,当我点击通知时,即使应用程序在当时打开,它也会再次打开应用程序。 请指教。

+0

,我想FLAG_ACTIVITY_CLEAR_TASK和FLAG_ACTIVITY_CLEAR_TOP到位的新任务。但没有运气 – shahriar

回答

0

好吧,我已经解决了。 增加了以下的menifest

android:launchMode="singleTask" 

,并加入我的mainactivity如BTW如下

protected void onNewIntent(Intent intent) 
    { 
     super.onNewIntent(intent); 
     String url = intent.getStringExtra("url"); 
     mWebView.loadUrl(url); 
    } 
相关问题