Hide application icon from launcher [duplicate]

半世苍凉 提交于 2020-01-03 06:40:07

问题


I have an android application. I want to hide app icon from launcher screen & make it visible again after dialing some no i.e "1234" . Any helpful code snippet will be appreciated.


回答1:


Have a look on this link. May be it will help you

hidden App

Edit 1:

First:

PackageManager p = getPackageManager();
p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

Second :

public class DialBroad extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

        if ((phoneNumber).equals("123456")) {
            Intent appIntent = new Intent(context, MainActivity.class);
            appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(appIntent);
            setResultData(null);
        } else {
            // Toast.makeText(context, phoneNumber, Toast.LENGTH_LONG).show();
        }
    }
}


来源:https://stackoverflow.com/questions/21954317/hide-application-icon-from-launcher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!