mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
post notification on receipt of url for new app that'll result it it's
being downloaded.
This commit is contained in:
parent
dfdaa500a7
commit
cd340aba0c
3 changed files with 24 additions and 8 deletions
|
@ -1999,5 +1999,7 @@
|
|||
<string name="gamel_menu_checkupdates">Check for updates</string>
|
||||
<string name="new_dict_avail">New Wordlist available</string>
|
||||
<string name="new_dict_availf">%s has been updated</string>
|
||||
<string name="new_app_availf">New app available</string>
|
||||
<string name="new_app_avail">Click to download</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -20,22 +20,22 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import javax.net.SocketFactory;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import android.content.Context;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import android.content.pm.PackageManager;
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
|
@ -349,8 +349,16 @@ public class NetUtils {
|
|||
nvp.add( new BasicNameValuePair( "version",
|
||||
String.format( "%d",
|
||||
versionCode ) ) );
|
||||
String result = runPost( post, nvp );
|
||||
DbgUtils.logf( "checkVersions: received: \"%s\"", result );
|
||||
String url = runPost( post, nvp );
|
||||
if ( null != url ) {
|
||||
Intent intent =
|
||||
new Intent( Intent.ACTION_VIEW, Uri.parse(url) );
|
||||
String title = Utils.format( context, R.string.new_app_availf,
|
||||
packageName );
|
||||
String body = context.getString( R.string.new_app_avail );
|
||||
Utils.postNotification( context, intent, title, body,
|
||||
url.hashCode() );
|
||||
}
|
||||
} catch ( PackageManager.NameNotFoundException nnfe ) {
|
||||
DbgUtils.logf( "checkVersions: %s", nnfe.toString() );
|
||||
}
|
||||
|
|
|
@ -144,6 +144,13 @@ public class Utils {
|
|||
|
||||
public static void postNotification( Context context, Intent intent,
|
||||
int titleID, String body, int id )
|
||||
{
|
||||
String title = context.getString( titleID );
|
||||
postNotification( context, intent, title, body, id );
|
||||
}
|
||||
|
||||
public static void postNotification( Context context, Intent intent,
|
||||
String title, String body, int id )
|
||||
{
|
||||
/* s_nextCode: per this link
|
||||
http://stackoverflow.com/questions/10561419/scheduling-more-than-one-pendingintent-to-same-activity-using-alarmmanager
|
||||
|
@ -155,7 +162,6 @@ public class Utils {
|
|||
PendingIntent.getActivity( context, ++s_nextCode, intent,
|
||||
PendingIntent.FLAG_ONE_SHOT );
|
||||
|
||||
String title = context.getString( titleID );
|
||||
Notification notification =
|
||||
new Notification( R.drawable.icon48x48, title,
|
||||
System.currentTimeMillis() );
|
||||
|
|
Loading…
Reference in a new issue