Broadcast

Broadcast receiver Activity

SDK Version: 
M3

If you want to catch a broadcasted intent on an Activity, you may get the following error:

  1. 02-22 08:18:46.874: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to instantiate receiver com.helloandroid.broadcasttest.BroadcastTestActivity$MyBroadcastReceiver:
  2. ...
  3. java.lang.InstantiationException: com.helloandroid.broadcasttest.BroadcastTestActivity$MyBroadcastReceiver
  4.  
  5.  
  6. ...
  7.  
  8. 02-22 08:18:46.874: E/AndroidRuntime(276): Caused by: java.lang.InstantiationException: com.helloandroid.broadcasttest.BroadcastTestActivity$MyBroadcastReceiver

Mastering Android Widget Development - Part3

SDK Version: 
M3

I just come to a new discovery regarding widgets. I was developing an appwidget, which - just like the widgets we are trying to make in this series of tutorials - and tried it out multiple phones. Unfortunatelly on one of our test phones it didn't function properly. For random intervals it stopped to refresh, and it din't responded to button presses on the widget, only after 1-2 minutes. After hard work I discivered the following:

Buttons on appwiget can have their onclick flunctionality thorough RemoteViews.setOnClickPendingIntent(). This method gets a PendingIntent ap parametes to bound to a button. PendingIntent's can have 3 types created with

getActivity(Context, int, Intent, int)


getBroadcast(Context, int, Intent, int)


and getService(Context, int, Intent, int).

Syndicate content