… | |
… | |
29 |
|
29 |
|
30 | public class ZANaviDriveHomeWidgetProvider extends AppWidgetProvider
|
30 | public class ZANaviDriveHomeWidgetProvider extends AppWidgetProvider
|
31 | {
|
31 | {
|
32 | // SimpleDateFormat df = new SimpleDateFormat("hh:mm:ss");
|
32 | // SimpleDateFormat df = new SimpleDateFormat("hh:mm:ss");
|
33 |
|
33 |
|
|
|
34 | static int dummy_number = 1;
|
|
|
35 |
|
34 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
|
36 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
|
35 | {
|
37 | {
|
36 | final int N = appWidgetIds.length;
|
38 | final int N = appWidgetIds.length;
|
37 |
|
39 |
|
38 | // loop for each app widget
|
40 | // loop for each app widget
|
… | |
… | |
44 | Intent intent = new Intent(context, com.zoffcc.applications.zanavi.Navit.class);
|
46 | Intent intent = new Intent(context, com.zoffcc.applications.zanavi.Navit.class);
|
45 | // but some data into the intent
|
47 | // but some data into the intent
|
46 | Bundle sendBundle = new Bundle();
|
48 | Bundle sendBundle = new Bundle();
|
47 | sendBundle.putLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type", Navit.NAVIT_START_INTENT_DRIVE_HOME);
|
49 | sendBundle.putLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type", Navit.NAVIT_START_INTENT_DRIVE_HOME);
|
48 | intent.putExtras(sendBundle);
|
50 | intent.putExtras(sendBundle);
|
|
|
51 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
49 | System.out.println("DH:W 001 B=" + sendBundle.describeContents());
|
52 | System.out.println("DH:W 001 B=" + sendBundle.describeContents());
|
50 | System.out.println("DH:W 001 B=" + sendBundle.toString());
|
53 | System.out.println("DH:W 001 B=" + sendBundle.toString());
|
51 | System.out.println("DH:W 002 I=" + intent.toString());
|
54 | System.out.println("DH:W 002 I=" + intent.toString());
|
52 |
|
55 |
|
53 | // if ZANavi main activity already running, then only bring to front, otherwise start it // Intent.FLAG_ACTIVITY_NEW_TASK
|
56 | // if ZANavi main activity already running, then only bring to front, otherwise start it // Intent.FLAG_ACTIVITY_NEW_TASK
|
54 | PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
57 | PendingIntent pendingIntent = PendingIntent.getActivity(context, dummy_number, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
55 | System.out.println("DH:W 003 I=" + pendingIntent.toString());
|
58 | System.out.println("DH:W 003 I=" + pendingIntent.toString());
|
|
|
59 |
|
|
|
60 | dummy_number++;
|
|
|
61 | if (dummy_number > 20000)
|
|
|
62 | {
|
|
|
63 | dummy_number = 1;
|
|
|
64 | }
|
56 |
|
65 |
|
57 | RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_home);
|
66 | RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_home);
|
58 | views.setOnClickPendingIntent(R.id.icon_widget_home, pendingIntent);
|
67 | views.setOnClickPendingIntent(R.id.icon_widget_home, pendingIntent);
|
59 |
|
68 |
|
60 | appWidgetManager.updateAppWidget(appWidgetId, views);
|
69 | appWidgetManager.updateAppWidget(appWidgetId, views);
|