У меня есть приложение, которое использует уведомления push-сообщения GCM. Когда я нажимаю уведомление на телефоны, которые я тестирую (HTC Desire C, Samsung mini и т. Д.), Он отлично работает. Уведомление - это URL-адрес приложения, в котором исправлены ошибки.BrowserActivity просочилось в окно
Что обычно происходит, так это то, что нажатие нажимается, когда браузер открывается и начинается загрузка. Как только загрузка будет завершена, пользователь может щелкнуть по уведомлению в розыгрыше уведомления, а приложение будет устанавливать/обновлять.
Проблема в том, что я пытаюсь запустить это на Motorola defy mini XT320. Он может получать push, но браузер открывается как секунда или так до закрытия, и загрузка не запускается.
Есть ли у кого-нибудь идеи, почему? Ниже описано, как я генерирую уведомление вместе с ошибкой. Я вижу, что диалоговое окно появляется в течение секунды с открытием браузера. Я знаю, что ошибка может иметь какое-то отношение к этому, поскольку это утечка оконной ошибки. Я не создаю это диалоговое окно, это часть активности браузера Android.
Заранее спасибо.
private static void generateNotification(Context context, String message) {
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
//Intent notificationIntent = new Intent(context, EntryActivity.class);
Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(message));
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}
.
05-31 15:39:01.940: V/InputMethodManager(1310): focusOut: [email protected] [email protected] winFocus=false
05-31 15:39:02.170: V/InputMethodManager(1310): focusOut: [email protected] [email protected] winFocus=false
05-31 15:39:02.180: V/browser(1310): BrowserActivity.onDestroy: [email protected]
05-31 15:39:02.290: E/WindowManager(1310): Activity com.android.browser.BrowserActivity has leaked window [email protected] that was originally added here
05-31 15:39:02.290: E/WindowManager(1310): android.view.WindowLeaked: Activity com.android.browser.BrowserActivity has leaked window [email protected] that was originally added here
05-31 15:39:02.290: E/WindowManager(1310): at android.view.ViewRoot.<init>(ViewRoot.java:259)
05-31 15:39:02.290: E/WindowManager(1310): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
05-31 15:39:02.290: E/WindowManager(1310): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
05-31 15:39:02.290: E/WindowManager(1310): at android.view.Window$LocalWindowManager.addView(Window.java:424)
05-31 15:39:02.290: E/WindowManager(1310): at android.app.Dialog.show(Dialog.java:241)
05-31 15:39:02.290: E/WindowManager(1310): at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
05-31 15:39:02.290: E/WindowManager(1310): at com.android.browser.BrowserActivity.onDownloadStart(BrowserActivity.java:3492)
05-31 15:39:02.290: E/WindowManager(1310): at com.android.browser.Tab$4.onDownloadStart(Tab.java:1349)
05-31 15:39:02.290: E/WindowManager(1310): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:388)
05-31 15:39:02.290: E/WindowManager(1310): at android.os.Handler.dispatchMessage(Handler.java:99)
05-31 15:39:02.290: E/WindowManager(1310): at android.os.Looper.loop(Looper.java:130)
05-31 15:39:02.290: E/WindowManager(1310): at android.app.ActivityThread.main(ActivityThread.java:3689)
05-31 15:39:02.290: E/WindowManager(1310): at java.lang.reflect.Method.invokeNative(Native Method)
05-31 15:39:02.290: E/WindowManager(1310): at java.lang.reflect.Method.invoke(Method.java:507)
05-31 15:39:02.290: E/WindowManager(1310): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
05-31 15:39:02.290: E/WindowManager(1310): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
05-31 15:39:02.290: E/WindowManager(1310): at dalvik.system.NativeStart.main(Native Method)
[edit1]
@Override
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message");
String message = intent.getExtras().getString("price");
Log.e(TAG, "message from gcm = " + message);
Uri Download_Uri = Uri.parse(message);
DownloadManager.Request r = new DownloadManager.Request(Download_Uri);
// This put the download in the same Download dir the browser uses
r.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "RR3UPGRADE");
// Notify user when download is completed
// (Seems to be available since Honeycomb only)
// r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
// Start download
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(r);
displayMessage(context, message);
// notifies user
generateNotification(context, message);
}
.
06-04 11:38:05.624: I/ActivityManager(207): Starting: Intent { act=android.intent.action.VIEW dat=content://downloads/all_downloads/63 typ=application/vnd.android.package-archive flg=0x10000001 cmp=com.android.packageinstaller/.PackageInstallerActivity } from pid 421
06-04 11:38:05.664: W/PackageParser(1203): Skipping dir: /all_downloads/63
06-04 11:38:05.664: W/PackageInstaller(1203): Parse error when parsing manifest. Discontinuing installation
OK. Я проследил ошибку logcat, и похоже, что что-то не так с загрузкой. 'W/PackageParser (1203): Пропуск файла:/all_downloads/63' <==>' if (! SourceFile.isFile()) {Slog.w (TAG, «Пропуск файла:» + mArchiveSourcePath); mParseError = PackageManager.INSTALL_PARSE_FAILED_NOT_APK; return null; } '. Похоже, загрузка не увенчалась успехом. – ozbek
У вас есть идеи о том, что я могу попытаться обойти это? – turtleboy
Я попытался разместить код downloadManager с помощью AsyncTask, поскольку я нашел поток, который указывает, что для загрузки .apk лучше всего сделать это асинхронно. Это не имело значения. – turtleboy