小编Ale*_*bor的帖子

如何使用Android studio中的DDMS向模拟器发送消息

我正在尝试在android中构建一个文本消息应用程序,代码可以工作,但唯一不对的是我无法使用DDMS向模拟器发送消息.我已经粘贴了下面的代码,以防万一有必要,我会立即拍摄屏幕

package com.example.oghenekaroedoh.sms;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;

/**
 * Created by OGHENEKARO EDOH on 15/04/2015.
 */
public class SMSReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent)
    {
        //---get the SMS message passed in---
        Bundle bundle = intent.getExtras();
        SmsMessage[] msgs = null;
        String str = "SMS from ";
        if (bundle != null)
        {
            //---retrieve the SMS message received---
            Object[] pdus = (Object[]) bundle.get("pdus");
            msgs = new SmsMessage[pdus.length];
            for …
Run Code Online (Sandbox Code Playgroud)

android ddms android-studio

6
推荐指数
4
解决办法
1万
查看次数

标签 统计

android ×1

android-studio ×1

ddms ×1