Android how to start an apk download from the notification drawer -


i've app can push notifications on via gcm. receive notification in notification drawer when click on it, activity app started(entryactivity). i'd happen if message in notification url .apk file eg 'http://path_to_file.apk', i'd file start downloading.

below code generates notification, there need add or change start download?

/**      * issues notification inform user server has sent message.      */     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);          // set intent not start 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 enabled         notification.defaults |= notification.default_vibrate;         notificationmanager.notify(0, notification);           } 

try this:

    intent notificationintent = new intent(intent.action_view, uri.parse("http://path_to_file.apk"));     notificationintent.setclassname("com.android.browser",                                 "com.android.browser.browseractivity"); 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -

matlab - How to equate a structure array to structure array -