Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved it myself. Actually I just wanted to check for internet connection by implementing this method:</p> <pre><code>public boolean isOnline(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null &amp;&amp; netInfo.isConnectedOrConnecting()) { return true; } else { return false; } } </code></pre> <p>But as it turns out this also solves my problem of getting no answer with a slow connection. I use it in the onReceive() like this:</p> <pre><code>@Override public void onReceive(Context context, Intent intent) { // Name of the action of the intent final String action = intent.getAction(); // Check for internet connection. Also solves problem of slow internet connection!!! if(isOnline(context) == true) { // Count down group by 1 if(COUNT_DOWN.equals(action)) { if(currentGroupOrderID + singleton.getCount() == 1) { Toast.makeText(context, "Kein vorheriger Spieltag in dieser Saison vorhanden.", Toast.LENGTH_SHORT).show(); } else { singleton.setCount(singleton.getCount()-1); updateWidgetData(context, intent); } } // Count up group by 1 if(COUNT_UP.equals(action)) { if(currentGroupOrderID + singleton.getCount() == maxNoOfGroups) { Toast.makeText(context, "Kein weiterer Spieltag in dieser Saison vorhanden.", Toast.LENGTH_SHORT).show(); } else { singleton.setCount(singleton.getCount()+1); updateWidgetData(context, intent); } } // Update current group if(UPDATE_WIDGET.equals(action)) { updateWidgetData(context, intent); } } else { Toast.makeText(context, "No internet connection", Toast.LENGTH_SHORT).show(); } super.onReceive(context, intent); } </code></pre> <p>Maybe this will help someone else. ;-)</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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