从应用程序列表中隐藏的Android应用程序并从广播接收器启动它 [英] android hide application from the list of applications and launch it from broadcast receiver
问题描述
我想隐藏的应用程序列表中我的应用程序,所以第三人不知道是否安装了此应用程序。
我看到,这可以通过以下方式实现:如果你想隐藏应用程序启动器应用程序,那么就没有包括android.intent.category.LAUNCHER您的任何活动。
我尝试这样做,这是工作。 现在,我需要定义一个快捷方式启动我的应用程序。
我想通过广播接收器呼出实现这一目标。因此,我将在我的onReceive检查拨打的号码=我的模式,然后启动我的活动
我有一些问题在这里
-
这是做这件事的正确方法
-
请参阅下面的接收器,在这里我得到接收机叫我code,但随着该系统的应用程序来处理数字拨号也被称为。所以,即使我拨打我的模式,显示我的活动之后,它使呼叫。我想停下来拨打电话,如果拨打的号码匹配我的模式。我怎样才能做到这一点
-
我发动我的活动作为一个新的任务。当我运行我的应用程序的第一次,我的活动画面来了。但是,当我再次拨打,它不是带到前面。我怎样才能做到这一点。我想,如果我解决我的previous的问题,这将是照顾。
公共类OutgoingCallInterceptor扩展的BroadcastReceiver {
@覆盖 公共无效的onReceive(上下文的背景下,意图意图){
最后弦乐originalNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); this.setResultData(0123456789); 最后弦乐newNumber = this.getResultData(); 弦乐味精=截获呼出老号+ originalNumber +,新号码+ newNumber; Toast.makeText(背景下,味精,Toast.LENGTH_LONG).show(); 意图intent1 =新的意图(背景下,ShowMessageActivity.class); intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent1);
}
}
<应用机器人:图标=@可绘制/图标机器人:标签=呼出拦截>
<接收器的Android版本:NAME =OutgoingCallInterceptor>
<意图过滤器的Android版本:优先级=1>
<作用机器人:名称=android.intent.action.NEW_OUTGOING_CALL>< /作用>
&所述; /意图滤光器>
< /接收器>
<活动机器人:名称=ShowMessageActivity>< /活性GT;
< /用途>
<使用-权限的Android:名称=android.permission.PROCESS_OUTGOING_CALLS>< /使用-许可>
公共类OpenApplication扩展的BroadcastReceiver {
@覆盖
公共无效的onReceive(上下文的背景下,意图意图){
串号= intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
字符串compare_num =777;
如果(number.equals(compare_num)){
意图myintent =新的意图(背景下,MainActivity.class);
myintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myintent);
// abortBroadcast();
setResultData(空);
}
}
}
<使用-权限的Android:名称=android.permission.PROCESS_OUTGOING_CALLS/>
<! - 打开程序 - >
<接收器的Android版本:NAME =receiver.OpenApplication>
<意图过滤器的Android版本:优先级=0>
<作用机器人:名称=android.intent.action.NEW_OUTGOING_CALL/>
&所述; /意图滤光器>
< /接收器>
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.
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 dialled = my pattern then launch my activity
I have some questions here
Is this the right way of doing it
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
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);
}
}
<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>
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>
这篇关于从应用程序列表中隐藏的Android应用程序并从广播接收器启动它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!