安卓——BroadcastReceiver
package com.example.administrator.myapplication_reciver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
/**
* Created by Administrator on 2018/1/1.
*/
public class Myreciver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String s=intent.getStringExtra("a")+intent.getStringExtra("a1");
Toast.makeText(context,s,Toast.LENGTH_LONG).show();
}
}
配置文件 AndroidManifest.xml <receiver android:name=".Myreciver">
<intent-filter>
<action android:name="reciver" />
</intent-filter>
</receiver>
3 Intent in =new Intent("reciver");
in.putExtra("a1","第二条是 你好啊,交个盆友吧!");
sendBroadcast(in);
send(v);
package com.example.administrator.myapplication_reciver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
/**
* Created by Administrator on 2018/1/1.
*/
public class Myreciver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String s=intent.getStringExtra("a")+intent.getStringExtra("a1");
Toast.makeText(context,s,Toast.LENGTH_LONG).show();
}
}
配置文件 AndroidManifest.xml <receiver android:name=".Myreciver">
<intent-filter>
<action android:name="reciver" />
</intent-filter>
</receiver>
3 Intent in =new Intent("reciver");
in.putExtra("a1","第二条是 你好啊,交个盆友吧!");
sendBroadcast(in);
send(v);
安卓——BroadcastReceiver
package com.example.administrator.myapplication_reciver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
/**
* Created by Administrator on 2018/1/1.
*/
public class Myreciver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String s=intent.getStringExtra("a")+intent.getStringExtra("a1");
Toast.makeText(context,s,Toast.LENGTH_LONG).show();
}
}
配置文件 AndroidManifest.xml <receiver android:name=".Myreciver">
<intent-filter>
<action android:name="reciver" />
</intent-filter>
</receiver>
3 Intent in =new Intent("reciver");
in.putExtra("a1","第二条是 你好啊,交个盆友吧!");
sendBroadcast(in);
send(v);