Skip to content

Commit

Permalink
阻止广播续传
Browse files Browse the repository at this point in the history
  • Loading branch information
ningbaoqi committed Jul 19, 2018
1 parent 78fe8eb commit b02a055
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
[静态注册广播](https://github.com/ningbaoqi/BroadcastReceiver/commit/693d5f9dd4c3f3ca02f9732ad572f7b8a42910a6)
### 动态注册广播
[动态注册广播](https://github.com/ningbaoqi/BroadcastReceiver/commit/221e1310a8102918c0444f1c33c278c50b802e03)
### 阻止广播续传
[阻止广播续传](https://github.com/ningbaoqi/BroadcastReceiver/commit/221e1310a8102918c0444f1c33c278c50b802e03)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class MainActivity extends AppCompatActivity {
Expand Down Expand Up @@ -58,6 +59,12 @@ public void sendOrderBroadcast(View view) {
class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String msg = intent.getStringExtra("msg");
Log.d("nbq", "msh : " + msg);
/**
* 阻止广播向其他广播接收器传递,只能阻止有序广播
* */
abortBroadcast();
}
}
}

0 comments on commit b02a055

Please sign in to comment.