我开发了 android 小部件应用程序并且它工作正常。现在我的客户问,当用户安装这个应用程序时,它需要自动放置在主屏幕的顶部位置。这该怎么做?请帮我。
我正在开发一个应用程序,它应该在安装后将其快捷方式添加到主屏幕,并在卸载应用程序后将其删除.应用程序将预先安装在最终用户设备上,但仍应具有卸载选项.任务看起来很简单,但我遇到了很多麻烦.
我做了什么:
我不能(并且几乎放弃):
无法使用Intent.ACTION_PACKAGE_REMOVED,因为要卸载的应用程序没有收到此意图.我执行了一些测试,发现使用该应用程序删除的唯一快捷方式是从菜单"添加到主屏幕=>快捷方式=>应用程序=>应用程序活动"创建的快捷方式.在卸载应用程序后,以编程方式创建或在AndroidManifest中声明的快捷方式仍保留在主屏幕上.
论坛上几乎没有关于这个主题的文档和帖子,我有点困惑为什么这样一个与Android安全策略不矛盾的简单操作无法直接实现.
有没有办法要求OS删除应用程序卸载时的相应快捷方式?我可以在删除应用程序之前捕获应用程序正在卸载的事件吗?
是否可以在一个apk文件中拥有多个应用程序?或者有一种方法可以在一个应用程序中为不同的活动设置不同的启动器图标吗?我想将我的应用程序分成一些不同的(但相关的)逻辑部分.
谷歌游戏商店有很多图标包,与发射器兼容,我只是想知道发射器是如何访问和识别这样的图标包所以它反映到发射器.
我成功编写了内部Icon pack
链接到启动器但是ow launcher accessing such icon pack, so it will handle appropriate icon pack and get reflect to launcher?
图标包中的代码,定义必要的启动程序包名称@
<!-- Go / Nova -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.gau.go.launcherex.theme" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- LauncherPro / Holo -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.fede.launcher.THEME_ICONPACK" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
我接受了XDA开发人员指南,但没有得到任何解决方案,任何人都可以解决问题吗?
我想知道Android Wear发射器如何像Swipify和Wear Mini Launcher一样拦截android Wear主屏幕上的触摸事件.
到目前为止,我已尝试将onTouch和onClick侦听器添加到我的应用程序中的Watch View Stub,但我无法弄清楚如何在我的应用程序之外进行触摸.
在我的主屏幕替换应用程序中,我必须获得所有已安装应用程序的列表,以将它们放入应用程序抽屉中.因此,以下方法可以在每个应用程序上运行;
public static App fromResolveInfo (Context context, PackageManager pacMan, AppManager appManager, ResolveInfo resInf)
{
String label = resInf.loadLabel (pacMan).toString ();
String packageName = resInf.activityInfo.applicationInfo.packageName;
String activityName = resInf.activityInfo.name;
App app = new App (context, appManager);
app.setLabel (label);
app.setPackageName (packageName);
app.setActivityName (activityName);
AppIcon icon = null;
if (appManager.isIconPackLoaded ())
icon = appManager.getIconPack ().getIconForApp (app);
if (icon == null)
icon = appManager.getIconPack ().getFallbackIcon (resInf.loadIcon (pacMan));
app.setIcon (icon);
return app;
}
Run Code Online (Sandbox Code Playgroud)
问题是这里存在瓶颈,而不是像我原先预料的那样加载图标.方法(String label = resInf.loadLabel (pacMan).toString ();
)的第一行可以占用0到250毫秒之间的任何地方(在相对高端的设备上).在旧设备上,这成为一个真正的问题.
在我的测试中,我注意到当较慢的设备是多任务处理并且由于某种原因必须重新加载应用程序抽屉时,完成此操作可能需要30秒(在所有已安装的应用程序上).
缓存可以为此提供潜在的解决方案,但是如果应用程序的名称发生变化(偶尔发生)会怎样?我必须从缓存中获取标签,然后在单独的线程中循环遍历所有应用程序并更正它们已更改的标签.这可能会提供一个解决方案,但它似乎更像是一个肮脏的黑客而不是一个真正的好解决方案. …
在我的Android应用程序中,我使用了一个库项目,我使用它的一个活动.但是在库项目中,该活动具有MAIN操作和LAUNCHER类别intent-filter.所以我将该活动添加到我的清单并删除了intent-filter.清单似乎正确地合并到build/intermediates/manifests/full/debug/AndroidManifest.xml中,活动看起来像预期的那样(没有intent-filter):
<activity
android:name="com.michaelrnovak.util.logger.Logger"
android:configChanges="orientation"
android:label="@string/show_log" >
</activity>
Run Code Online (Sandbox Code Playgroud)
但是,当我在模拟器中从AndroidStudio启动应用程序时,将启动库的Logger活动,而不是我的AlertsActivity.我究竟做错了什么?
这是图书馆的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.michaelrnovak.util.logger"
android:versionCode="8"
android:versionName="1.5">
<uses-permission android:name="android.permission.READ_LOGS" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name=".Logger"
android:label="@string/app_name"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
Run Code Online (Sandbox Code Playgroud)
我的应用程序清单具有以下相关活动定义:
<activity
android:name=".AlertsActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
</activity>
<activity android:name="com.michaelrnovak.util.logger.Logger"
android:label="@string/show_log"
android:configChanges="orientation"
tools:replace="android:label"
>
<intent-filter tools:node="removeAll" />
</activity>
Run Code Online (Sandbox Code Playgroud) merge android intentfilter android-manifest android-launcher
我正在为自己创造新的发射器.现在,当我从我的主要活动中运行应用程序时,它有这个默认动画,它将我的启动器放在后面并在其上弹出新应用程序.而不是这个,我想附加我自己的动画.最好我想默认从触摸点显示的素材动画.
到目前为止我尝试过的事情:
您需要在Android上使用此活动的Theme.AppCompat主题(或后代)
http://tips.androidhive.info/2015/09/android-how-to-apply-material-design-theme/
<style name="swLaunch" parent="swLaunch.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/explode</item>
<item name="android:windowSharedElementExitTransition">@android:transition/explode</item>
<item name="android:windowEnterAnimation">@android:transition/explode</item>
<item name="android:windowExitAnimation">@android:transition/explode</item>
<item name="android:taskToFrontEnterAnimation">@android:transition/explode</item>
<item name="android:taskToBackEnterAnimation">@android:transition/explode</item>
<item name="android:taskToFrontExitAnimation">@android:transition/explode</item>
<item name="android:taskToBackExitAnimation">@android:transition/explode</item>
<item name="android:inAnimation">@android:transition/explode</item>
<item name="android:layoutAnimation">@android:transition/explode</item>
<item name="android:windowShowAnimation">@android:transition/explode</item>
<item name="android:activityOpenEnterAnimation">@android:transition/explode</item>
<item name="android:fragmentOpenEnterAnimation">@android:transition/explode</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这就是我启动应用程序的方式:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.android.gm");
if (launchIntent != null) {
startActivity(launchIntent);
}
Run Code Online (Sandbox Code Playgroud) 我在 api 26 中的启动器图标有一个大问题
我有透明背景的png,但它在透明部分变黑
这是结果:
这不是主题,因为其他应用程序没有背景
这是我的清单:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="false"
android:theme="@style/AppTheme">
Run Code Online (Sandbox Code Playgroud)
这是 api 26 的代码
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
Run Code Online (Sandbox Code Playgroud)
这是 ic_launcher_background 文件,它是一个透明图像:
这是 ic_launcher_foreground 文件:
我该如何解决这个问题?我怎样才能摆脱黑色背景?
android ×10
android-launcher ×10
assets ×1
homescreen ×1
intentfilter ×1
java ×1
merge ×1
performance ×1
wear-os ×1
widget ×1
workspace ×1