从抽屉中取出的应用程序图标没有在安卓4.1工作(Remove app icon from Drawe

2019-10-18 05:00发布

我有它安装在用户的电话,仍然从应用程序抽屉隐藏的应用程序,来实现这一点,只是去掉意图过滤器标签的问题,下面ICS 4.0一切这项工作很好,任何帮助,得到它的工作在ICS?

这部作品在姜饼和Froyo的罚款,开始我的活动,并不断从抽屉中隐藏的应用程序图标,

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

但在ICS不工作,如果我删除此行的活动无法启动,任何想法,为什么?

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

这是我的拨号键盘监听器的代码

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)*/
        }

    }
}

Answer 1:

在情况下,任何人都碰到这个在未来,我发现了一种从案件程序抽屉它不通过移除意图过滤器做隐藏应用程序图标:

//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();
}


文章来源: Remove app icon from Drawer not working in Android 4.1