我想从应用程序列表中隐藏我的应用程序,这样第三个人就不会知道这个应用程序已安装。
我看到这可以通过以下方式实现:如果您想从Application Launcher中隐藏您的应用程序,那么就不要在任何活动中包含android.intent.category.LAUNCHER
。
我试过这个并且它正在工作。现在我需要定义一个启动我的应用程序的快捷方式。
我试图通过广播接收器来实现这一点。所以我会检查我的onreceive
,如果拨打的号码=我的模式然后启动我的活动
我在这里有一些问题
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>
但是,如果按照应用程序列表表示所有已安装的应用程序,那么我想您无法使用
<action android:name="android.intent.action.CREATE_SHORTCUT" />
创建快捷方式
而你的其他要求无法实现,因为我没有找到一种方法来隐藏我的应用程序,除了手机是个人设备。你可以使用广播接收器知道何时启动拨号器意图。但我想你再也无法得到键入的键是一个不同的应用程序。
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>