Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've managed this in an app by using a SharedPreferences value as to whether the activity is visible or not:</p> <pre><code> @Override protected void onStart() { super.onStart(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("RVisibleNow",true); editor.commit(); } </code></pre> <p>and</p> <pre><code> @Override protected void onStop() { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("RVisibleNow",false); editor.commit(); super.onStop(); } </code></pre> <p>then, yes, using a BroadcastReceiver such as:</p> <pre><code>private BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String theRow = intent.getStringExtra(GCMIntentService.MESSAGE); String theQuery="SELECT * FROM listdata WHERE _id ='" + theRow + "'"; String action = intent.getAction(); if(action.equals("com.you.yourapp.UpdateList")){ ... </code></pre> <p>Oh, and in your GCM service:</p> <pre><code>public static final String BROADCAST = "com.you.yourapp.UpdateList"; public static final String MESSAGE = "com.you.yourapp.GCMIntentService.MESSAGE"; ... if(RVisibleNow){ sendBroadcast(context, message, insertOrUpdate); }else{ generateNotification(context, message, insertOrUpdate); } </code></pre> <p>In my case, with a lot of omitted code, my sendBroadcast looked like:</p> <pre><code>private void sendBroadcast(Context context, String message, String whichFunction){ String putExtraParam = "something"; Intent in = new Intent(BROADCAST); in.putExtra(MESSAGE, putExtraParam); context.sendBroadcast(in); } </code></pre> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload