Android reboots when I try to set a service foreground -


I have behaved awkwardly in my app: when I try to set a service foreground, the handset (HTC G 1 +

This works when I do not try to service the foreground.

Here is the code flawed:

  notification notification = New Notification (RDWable.Con, GetText (R.Streact.TickerText), System Syrtetime Millis ()); StartForeground (SERVICE_NOTIFICATION_ID, Notification); Law V (tag, "forward control service.");   

Can you see where the problem is?

If you want more data then the entire project Can be found at GitHub:

Thanks.

This Android API demo Instead of calling startForeground () , note that this calls startForegroundCompat () , a wrapper that handles your request based on the new / old startForeground API

  zero handle com (Intent to intent) {if (ACTION_FOREGROUND.equals (intent.getAction ()) {... // icon, scroll text and timestamp notification notification = new notification (R.drawable.stat_sample, text, System.currentTimeMillis ()) ; // The pending provider to launch our activity if the user submits pending pending content of this information = get the pending notice (this, 0, the new intent (this, the controller class), 0); // Set the information for ideas shown in the Notification panel. Notification.SetlatestInvestInfo (this, GetText (R.string.local_service_label), Text, ContentIncentant); StartForegroundCompat (R.string.foreground_service_started, Notification); ...}   

This is startForegroundCompat () :

  / ** * This is a new cover wrapping around Method, using the old * API if it is not available. * / Zero Start OrientationCippet (Int ID, Notification Notification) {// If we have a new starting FII, then use it. If (mStartForeground! = Null) {mStartForegroundArgs [0] = integer.value (id); MStartForegroundArgs [1] = Information; InvokeMethod (mStartForeground, mStartForegroundArgs); Return; } // Returning to the old API MSetForegroundArgs [0] = Boolean. TRUE; InvokeMethod (mSetForeground, mSetForegroundArgs); MNM.notify (ID, notification); }    

Comments