broadcastreceiver - what is the drawback of sendSticyBroadcast() in Android? -


i developing android application in api level 21, broadcasting message unusual things happens. application can using it.

can me out in how send sticky broadcast in api 21.

    //myactivity.java     class myactivity extends activity {      //mydialog dialog initialized in oncreate      ...      private class myreceiver extends broadcastreceiver {         @override         public void onreceive(context context, intent intent) {             //toast "broadcast received"         }     } }  //mydialog.java class mydialog extends dialog {      //m_context = incoming context myactivity      @override     protected void oncreate(bundle savedinstancestate) {          button button1 = (button)findviewbyid(r.id.button1);         button1.setonclicklistener(new view.onclicklistener() {              @override             public void onclick(view v) {                 intent intent = new intent();                 m_context.sendstickybroadcast(intent);             }         });      }  }   //androidmanifest.xml <activity android:name=".myactivity" /> <receiver android:name="myreceiver" android:enabled="true">     <intent-filter >         <action android:name="android.intent.action.run"/>     </intent-filter> </receiver> 

yes have foud answer after googling lot.

this method deprecated in api level 21. sticky broadcasts should not used. provide no security (anyone can access them), no protection (anyone can modify them), , many other problems. recommended pattern use non-sticky broadcast report has changed, mechanism apps retrieve current value whenever desired.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -