简体   繁体   English

从Drawer中删除无法在Android 4.1中使用的应用程序图标

[英]Remove app icon from Drawer not working in Android 4.1

I have an app that its installed in the user's phone and remains hidden from the Applications Drawer, to achieve this it was only a matter of removing the intent-filter tags, this work fine for everything below ICS 4.0, any help to get it working in ICS? 我有一个应用程序,它安装在用户手机中,并且对应用程序抽屉隐藏,要实现此目的,只需删除intent-filter标签即可,对于ICS 4.0以下的所有组件都可以正常工作,任何帮助使其正常工作的功能在ICS中?

This works fine in gingerbread and froyo, starts my activity and keeps hidden the App Icon from the drawer, 在姜饼和冷冻面包中效果很好,可以开始我的活动,并从抽屉中隐藏应用图标,

<activity
     android:label="@string/app_name"
     android:name=".DashboardActivity" >
</activity>

but not working in ICS, if i remove this lines the activity wont start, any ideas why? 但不能在ICS中工作,如果我删除了此行,活动将无法开始,为什么会有任何想法?

     <intent-filter>
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>

This is the code for my Dialpad listener 这是我的Dialpad侦听器的代码

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

public class DialpadLauncher extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        Bundle bundle = intent.getExtras();
        if (null == bundle)
            return;
        // outgoingNumber=intent.getStringExtra(Intent.ACTION_NEW_OUTGOING_CALL);
        String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

        if (phoneNumber.equals("#00008#")){
            //START APPLICATION HERE
            //Toast.makeText(context,"DIALED: " + phoneNumber, Toast.LENGTH_LONG).show();

            try {
                Intent activity = new Intent(context, DashboardActivity.class);
                activity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(activity);
                setResultData(null);

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }  
            // catch not found (only works on HTC phones)*/
        }

    }
}

In case that anyone bumps into this in the future, i found a way to hide App Icon from the drawer programmatically in case it doesnt do it by removing the intent-filter: 万一将来有人碰到这个问题,我找到了一种方法,可以通过删除intent过滤器以编程方式从抽屉中隐藏应用程序图标,以防万一它不这样做:

//Disable Launcher icon from drawer if higher than Android 2.3
try {
     ComponentName componentToDisable =  new ComponentName("com.your.packagename", "com.your.packagename.ActivityName");
     getPackageManager().setComponentEnabledSetting(componentToDisable, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
} catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
}

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

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