如何通过使用Android代码使用呼叫拨号程序(键盘)启动隐藏的应用程序? [英] How to start hidden app by using call dialer(keypad) using Android code?

查看:549
本文介绍了如何通过使用Android代码使用呼叫拨号程序(键盘)启动隐藏的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过编程方式拨打某些预定义的号码来启动我的应用程序,这是一个隐藏的应用程序,例如*#*#111#*#*.我打开拨号程序并输入*#*#111#*#*.然后我的应用程序接收广播并开始播放.我应该听吗?

I want to start my app which is a hidden app by dialing certain predfined number by me programatically ,for eg *#*#111#*#*.I open the dialer and input *#*#111#*#*.Then My app receives the broadcast and starts.Which broadcast should I listen?

推荐答案

您应该输入数字*#*#xxxx#*#*,例如*#*#110#*#*.

You should input number *#*#xxxx#*#*, say, *#*#110#*#*.

创建接收方:

import android.content.BroadcastReceiver;

import android.content.Context;

import android.content.Intent;

public class Listener extends BroadcastReceiver {

@Override

public void onReceive(Context context, Intent intent) {

String pwd = intent.getData().getHost();

Intent i = new Intent(context, CalllistenerActivity.class);

i.putExtra("data", pwd);

i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

context.startActivity(i);

}

}

创建活动:

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class CalllistenerActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        String pwd = getIntent().getStringExtra("data");
        tv.setText(TextUtils.isEmpty(pwd)?"Plz input *#*#123#*#* in dial" :pwd);
        setContentView(tv);
    }
}

注册AndroidManifest:

Register in AndroidManifest:

<activity android:name=".CalllistenerActivity" android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<receiver android:name="Listener">
    <intent-filter>
        <action android:name="android.provider.Telephony.SECRET_CODE" />
        <data android:scheme="android_secret_code" android:host="110"/>
    </intent-filter>
</receiver>

您应该

这篇关于如何通过使用Android代码使用呼叫拨号程序(键盘)启动隐藏的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆