java - getting action of buttons on receive() method which is a method of broadcast receiver but its show a null -


i getting action of buttons getaction on receive() method method of broadcast receiver sho null plz tell me in value not null +my notify method following

private void notify(string notificationtitle, string notificationmessage)      {         string ns=context.notification_service;         notificationmanager notificationmanager=(notificationmanager)getsystemservice(ns);         @suppresswarnings("deprecation")         notification notification=new notification(r.drawable.bg,"time",system.currenttimemillis());         remoteviews notificationview=new remoteviews(getpackagename(),r.layout.main);         intent notificationintent=new intent(this,playeraudioactivity.class);         pendingintent pendingnotificationintent=pendingintent.getactivity(this, 0, notificationintent, 0);          notification.contentview=notificationview;         notification.flags|=notification.flag_no_clear;         //supposed button call intent         intent switchintent=new intent(this,myreceiver.class);         pendingintent pendingintent=pendingintent.getbroadcast(this, 0, switchintent, 0);         notificationview.setonclickpendingintent(r.id.btnprevious, pendingintent);         notificationmanager.notify(1, notification);     } 

-my broadcastreceiver class following

public class myreceiver  extends broadcastreceiver {      private static final string tag = "waaaawooooooooooooooojnjkhdfku";      public void onreceive(context context, intent intent) {          final string action=intent.getaction();         // if(appwidgetmanager.action_appwidget_deleted.equals(action)){         log.d(tag, ""+action); //           bundle extras=intent.getextras(); //           string iestring=extras.getstring("locale");     //       try{ //               final int appwidgid=extras.getint(appwidgetmanager.extra_appwidget_id,appwidgetmanager.invalid_appwidget_id); //               if(appwidgid!=appwidgetmanager.invalid_appwidget_id) //               { //                   this.ondeleted(context, new int[] { appwidgid }); //               } //            else { //                onreceive(context, intent); //                 } //              context.startservice(new intent(context,playeraudioactivity.class)); //              log.i(tag,"starting service connectivitylistener"); //          }catch(exception e){ //              log.e(tag,e.tostring()); //          } //       }     }      private void ondeleted(context context, int[] is) {         // todo auto-generated method stub      }  } 

+manifest file following

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.audio.audioplayer"     android:versioncode="1"     android:versionname="1.0" >      <uses-sdk         android:minsdkversion="8"         android:targetsdkversion="19" /> <uses-permission android:name="android.permission.access_network_state" />     <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >        <receiver android:name=".myreceiver" android:enabled="true">   <intent-filter>         <action android:name="android.net.wifi.wifi_state_changed"/><action    android:name="android.net.conn.connectivity_change"/><action   android:name="android.net.conn.data_activity_change"/> </intent-filter> </receiver>         <activity             android:name="com.audio.audioplayer.playeraudioactivity"             android:label="@string/app_name"              android:screenorientation="portrait"             >             <intent-filter>                 <action android:name="android.intent.action.main" />                  <category android:name="android.intent.category.launcher" />                 <data android:scheme="tel" />             </intent-filter>         </activity>         <activity             android:name=".playlistactivity"             android:label="@string/app_name"              android:screenorientation="portrait"              >         <meta-data             android:name="android.support.parent_activity"             android:value="com.audio.audioplayer.playeraudioactivity" />          </activity>     </application>  </manifest> 

as adamp mentioned in post cannot access action on intent you've not set:

{...} //supposed button call intent intent switchintent=new intent(this, myreceiver.class); pendingintent pendingintent=pendingintent.getbroadcast(this, 0, switchintent, 0); {...} 

you have add designated action intent using setaction().

something this:

{...} intent switchintent=new intent(this, myreceiver.class); switchintent.setaction("your_action"); pendingintent pendingintent=pendingintent.getbroadcast(this, 0, switchintent, 0); {...} 

ps: pseudo code


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -