内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

android無序廣播發(fā)送與接收實例

鄭州app開發(fā)android無序廣播發(fā)送與接收實例。思路如下,需要建立兩個工程。其中一個是發(fā)送無序廣播,另外一個是接收廣播。

創(chuàng)新互聯(lián)建站-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比東城網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式東城網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋東城地區(qū)。費用合理售后完善,十多年實體公司更值得信賴。

發(fā)送廣播的java代碼

package cn.xhhkj.cyd;

import androidx.appcompat.app.AppCompatActivity;

import android.app.pendingIntent;

import android.content.broadcastReceiver;

import android.content.Context;

import android.content.Intent;

import android.content.IntentFilter;

import android.content.Sharedpreferences;

import android.os.bundle;

import android.telephony.SmsManager;

import android.text.TextUtils;

import android.util.Log;

import android.view.View;

import android.widget.button;

import android.widget.EditText;

import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private button btn;

    @Override

    protected void onCreate(bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        btn=findViewbyId(R.id.btn);

        btn.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                Intent intent=new Intent();

                intent.setAction("cn.xhhkj.broadcast");

                intent.putExtra("key","hello");

                sendbroadcast(intent);

            }

        });

    }

}

接收無序廣播的java代碼

package cn.xhhkj.xhhkjtest;

import android.content.broadcastReceiver;

import android.content.Context;

import android.content.Intent;

import android.util.Log;

public class Mybroadcast extends broadcastReceiver {

    private static final String TAG = "MyReceiver";

    @Override

    public void onReceive(Context context, Intent intent) {

        Log.d(TAG,"接收到了"+intent.getStringExtra("key"));

    }

}

最后調(diào)試成功的代碼

2020-02-18 13:04:38.669 2876-2876/cn.xhhkj.xhhkjtest D/MyReceiver: 接收到了hello

網(wǎng)頁題目:android無序廣播發(fā)送與接收實例
文章地址:http://www.rwnh.cn/article48/scciep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站維護、外貿(mào)建站網(wǎng)頁設(shè)計公司、動態(tài)網(wǎng)站、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
丰城市| 松桃| 修武县| 房山区| 阿荣旗| 仙居县| 泸水县| 防城港市| 大连市| 罗源县| 拜泉县| 建阳市| 临武县| 右玉县| 玉屏| 泰和县| 台东县| 聂荣县| 垣曲县| 马尔康县| 崇明县| 孟州市| 长治市| 嵊泗县| 长白| 疏勒县| 宽城| 青岛市| 红安县| 南溪县| 常熟市| 资兴市| 阜新市| 镇雄县| 绥棱县| 改则县| 商城县| 桂平市| 邢台县| 隆尧县| 临泉县|