从启动器中删除但保持启用/可启动

发布于 2024-10-18 02:00:58 字数 911 浏览 4 评论 0原文

我尝试编码它,我尝试用谷歌和stackoverflow解决它,没有找到:=)所以希望其他人有更好的想法,我不确定我是否一切都正确:

我有2个应用程序:广告(主应用程序)/无广告-专业版(只需许可证启动没有广告的广告应用程序;P)

所以问题是,我想在启动器中有一个专业版(带有专业图标),它启动普通广告应用程序,即(普通广告-app)不在启动器中。

我尝试从启动器中删除广告应用程序(根据我的研究,应该将其从启动器中删除)

pkgMgr.setComponentEnabledSetting(new ComponentName(PACKAGE_NAME, PACKAGE_NAME + ".Main"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED、PackageManager.DONT_KILL_APP);

结果是:启动器中的图标是正确的;)但是无法在手机上找到该应用程序、启动、启动,甚至不使用启动器专业版活动快捷方式。它似乎在那里(可以创建快捷方式),但是当我尝试启动它时,我因活动异常而崩溃。

02-18 14:38:59.237:错误/AndroidRuntime(9941):导致:android.content.ActivityNotFoundException:无法找到显式活动类{PACKAGE_NAME/PACKAGE_NAME.Main};您是否在 AndroidManifest.xml 中声明了此活动?

这似乎不属于(错误消息) 看起来应用程序发生的事情不仅仅是简单地删除启动器中的条目。

非常感谢大家, 对于这种情况的每一种解决方法表示赞赏:) 此致 :)

i tried coding it, i tried solving it with google and stackoverflow, nothing found :=) so hopefully someone else has a better idea, im not sure if i get everything right:

i have 2 applications: ad (main app) / adfree-pro (just license starts ad app without ads ;P)

so the problem is, i want to have a pro version (with pro icon) in the launcher, which starts the normal-ad app, which is (the normal ad-app) not in the launcher.

i tried removing the ad-app from the launcher (which due to my research should JUST remove it from the launcher)

pkgMgr.setComponentEnabledSetting(new ComponentName(PACKAGE_NAME, PACKAGE_NAME + ".Main"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

which results to: the icons in the launcher are correct ;) BUT the application can't be found on the phone, launched, started, even not with a launcher pro activity shortcut. it seems to be there (shortcuts can be created) but i crashes with an activity exception when i try to launch it.

02-18 14:38:59.237: ERROR/AndroidRuntime(9941): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {PACKAGE_NAME/PACKAGE_NAME.Main}; have you declared this activity in your AndroidManifest.xml?

which doesnt seem to belong (the error message)
it looks like there has happened more to the application than just simply removed the entry in the launcher.

thanks a lot guys,
every workaround for this situation appreciated :)
best regards :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谈场末日恋爱 2024-10-25 02:00:58

您无法安装应用程序并隐藏其启动器图标。我用我的应用程序解决这个问题的方式与你的应用程序类似,我不会尝试与图标战斗,而是可以使用以太图标启动该应用程序。显然,您不必在主(免费)应用程序中执行此操作,从专业图标启动应用程序的代码将如下所示:

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    // check if main app is installed. If yes then start it
    if (appExists()) {
        Log.d(TAG, "Started main app from Pro");
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("myapp://com.myapp.main"));
        startActivity(intent);
        finish();
    } else {
        // display view with link back to Market 
        onAppNotExists();
    }
}

由您来实现 appExists() ,即可能是某种许可证检查

当然,您也可以将应用程序的通用代码开发为 library项目,然后以两种方式分发它,而无需重复代码

You can't have app installed and hide it's launcher icon. The way I'm addressing it with my application which works similar to yours that I don't try to fight icons but instead the app can be launched using ether icon. Obviously you don't have to do in the main (free) app and the code that launches app from your pro icon will look something like the following:

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    // check if main app is installed. If yes then start it
    if (appExists()) {
        Log.d(TAG, "Started main app from Pro");
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("myapp://com.myapp.main"));
        startActivity(intent);
        finish();
    } else {
        // display view with link back to Market 
        onAppNotExists();
    }
}

It's up to you to implement appExists() which is probably some sort of license check

Of course, alternatively you can develop your app's common code as library project and then distribute it in 2 flavors without duplicating the code

叫思念不要吵 2024-10-25 02:00:58

但是应用程序无法在手机上找到、启动、启动,
即使没有启动器专业活动快捷方式。

不是应用程序,而是活动。

因此,如果您的 LAUNCHER 活动是 BaseActivity,您可以创建类似 BaseFakeActivity 的内容(不要忘记将其设置为 >LAUNCHER 在你的清单中,而不是你的 BaseActivity),其唯一的功能是启动你的 BaseActivity 然后 finish() 本身。

现在您可以隐藏您的 BaseFakeActivity,但您仍然可以与您的 BaseActivity 进行交互。

PS:在这样做之后,不要忘记测试应用程序的行为;)

BUT the application can't be found on the phone, launched, started,
even not with a launcher pro activity shortcut.

Not application, but activity.

So, if your LAUNCHER activity is BaseActivity, you may create something like BaseFakeActivity (don't forget to set it as LAUNCHER in your manifest instead of your BaseActivity) and which only function is to start your BaseActivity and then finish() itself.

Now you may hide your BaseFakeActivity but you'll still be possible to interact with your BaseActivity.

P.S.: Don't forget to test your app's behaviour after doing things this way ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文