简体   繁体   English

android从应用程序列表中隐藏应用程序并从广播接收器启动它

[英]android hide application from the list of applications and launch it from broadcast receiver

I want to hide my app from the list of applications so a third person will not know that this app is installed.我想从应用程序列表中隐藏我的应用程序,这样第三方就不会知道安装了这个应用程序。

I saw that this can be achieved by : If you want to hide your application from Application Launcher, then just do not include android.intent.category.LAUNCHER in any of your activities.我看到这可以通过以下方式实现:如果您想从应用程序启动器中隐藏您的应用程序,那么请不要在您的任何活动中包含android.intent.category.LAUNCHER

I tried this and it is working .我试过了,它正在工作。 Now i need to define a shortcut to launch my app.现在我需要定义一个快捷方式来启动我的应用程序。

I am trying to achieve this by a broadcast receiver for outgoing call .我正在尝试通过广播接收器来实现这一目标。 SO i will check in my onreceive if the number dialed = my pattern then launch my activity onreceive如果拨打的号码 = 我的模式,我将检查我的onreceive ,然后启动我的活动

I have some questions here我在这里有一些问题

  1. Is this the right way of doing it这是正确的做法吗

  2. Please see my code below for receiver, here my receiver get called, but along with that system app to handle "number dial" is also called.请参阅下面的接收器代码,这里我的接收器被调用,但与处理“拨号”的系统应用程序一起也被调用。 So even if I dial my pattern, after showing my activity, it makes the call.因此,即使我拨打我的模式,在显示我的活动后,它也会拨打电话。 I want to stop making call if the number dialed matches my pattern.如果拨打的号码符合我的模式,我想停止拨打电话。 How can I achieve this我怎样才能做到这一点

  3. I am launching my activity as a new task.我正在启动我的活动作为一项新任务。 When I run my app for the first time, my activity screen is coming.当我第一次运行我的应用程序时,我的活动屏幕即将出现。 But when i dial again, its not brought to front.但是当我再次拨号时,它没有被带到前面。 How can I achieve this.我怎样才能做到这一点。 I think if I solve my previous question, this will be taken care.我想如果我解决了我之前的问题,这将得到照顾。

     public class OutgoingCallInterceptor extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { final String originalNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); this.setResultData("0123456789"); final String newNumber = this.getResultData(); String msg = "Intercepted outgoing call. Old number " + originalNumber + ", new number " + newNumber; Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); Intent intent1 = new Intent(context,ShowMessageActivity.class); intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent1); } }

Menifest File清单文件

<application android:icon="@drawable/icon" android:label="Outgoing Call Interceptor">

    <receiver android:name="OutgoingCallInterceptor">
        <intent-filter android:priority="1">
            <action android:name="android.intent.action.NEW_OUTGOING_CALL"></action>
        </intent-filter>
    </receiver>
    <activity android:name="ShowMessageActivity" ></activity>

</application>

<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>

But if by list of apps you mean to say all installed apps then I guess that is not possible you can use但是,如果通过应用程序列表,您的意思是说所有已安装的应用程序,那么我想这是不可能的,您可以使用

<action android:name="android.intent.action.CREATE_SHORTCUT" />

to create shortcut创建快捷方式

And for rest of your requirements cant be acheived as I havent found a way to hide my app this way and besides cellphones are personal devices.And you can use a broadcast reciever to know when dialer intent is launched.But again I guess you cannot get the key typed as its all together a different app.对于您的其他要求无法实现,因为我还没有找到以这种方式隐藏我的应用程序的方法,而且手机是个人设备。而且您可以使用广播接收器来了解拨号意图何时启动。但我想您再次无法获得键入的键是一个不同的应用程序。

  1. It isn't a right, but maybe the only way to do that :)这不是正确的,但也许是唯一的方法:)
  2. You can try to call this.abortBroadcast() on your receiver to abort call.您可以尝试在接收器上调用 this.abortBroadcast() 以中止呼叫。 Unfortunately I can't check it now, but it should be working.不幸的是,我现在无法检查它,但它应该可以工作。
public class OpenApplication extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    String compare_num = "777";
    if (number.equals(compare_num)) {
        Intent myintent = new Intent(context, MainActivity.class);
        myintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(myintent);
    //  abortBroadcast();
        setResultData(null);
    }
}

} }

   <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />

   <!-- OPEN APP -->
    <receiver android:name="receiver.OpenApplication" >
        <intent-filter android:priority="0" >
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        </intent-filter>
    </receiver>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM