我是Android编程的新手,我希望我的应用程序在安装后隐藏应用程序图标。我将使用我的论文代码。谢谢。
答案 0 :(得分:1)
首先,你必须制作这样的接收器..
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String phoneNubmer = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
if (LAUNCHER_NUMBER.equals("**11**")) {
PackageManager p = context.getPackageManager();
ComponentName componentName = new ComponentName(context, MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
} else if (LAUNCHER_NUMBER.equals("**22**")) {
ComponentName componentToEnable = new ComponentName(getApplicationContext(), MainActivity.class);
PackageManager pm = getApplicationContext().getPackageManager();
pm.setComponentEnabledSetting(componentToEnable, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}
}
}
将此权限添加到清单。
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
将其注册到清单文件。
<receiver android:name=".MyReceiver" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
享受编码...