我有一个自定义家庭应用程序启动器
所以我可以控制主页键返回键和菜单键我做我需要的但是在我的平板电脑上10.1"IPS双核Artview我有4个按钮
- 后面,一个带箭头 - 一个家,一个有一个小房子 - 最近的应用程序,看起来像2个叠加的盒子(以及谁在出版社显示最近的应用程序) - 菜单,3点小点
我的问题是我不想在第3个按钮上做自定义思考,但android系统不让我...
无论如何要这样做?如果我有4个按钮可能我没有使用正确的键码为第二个
如何在android中的应用程序启动器图标中识别click事件?一旦用户点击此图标,我需要进入主屏幕.例如,假设这是清单文件:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
..........
Run Code Online (Sandbox Code Playgroud)
在main activity
里面使用以下代码段onCreate()
actionBar=getActionBar();
actionBar.setHomeButtonEnabled(true);
Run Code Online (Sandbox Code Playgroud)
应用程序图标是可点击的.我没有任何方法可以检测到此事件的点击事件.这可能在android中做.有什么建议吗?
问题表明我知道我们无法覆盖Home键事件但是如果你看看android 2.2的模拟器,你会看到一个应用程序Car Home它已经覆盖了大多数键,如Home,end call.
现在,关键是他们是如何做到的?我试图窥视应用程序的源代码,但令我惊讶的是它不可用或我无法找到它,但我不认为以后是这种情况.
我正在 Android Ice Cream Sandwich 中创建一个启动器应用程序。
我有 3 项活动。这就是它们在清单文件中声明的方式。
<activity
android:label="@string/app_name"
android:name=".ActivityOne"
android:theme="@android:style/Theme.Light.NoTitleBar"
>
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activitytwo"
android:theme="@android:style/Theme.Light.NoTitleBar">
</activity>
<activity android:name=".ActivityThree"
android:theme="@android:style/Theme.Light.NoTitleBar">
</activity>
Run Code Online (Sandbox Code Playgroud)
在手机中安装 apk 并按系统栏中的 Home 键后,我将进入“ActivityOne”。这工作得很好。
然后我创建了一个密钥来签署 apk。从 Eclipse 导出项目并对 apk 进行签名。现在按Home键没有任何作用。
我需要应用程序在签名后以与原来相同的方式工作。
有任何想法吗 ?
我正在为Android的主屏幕替换启动器应用。我想向其添加小部件(本机应用程序小部件)。我怎么能够 ?我尝试了许多方法,但它们要么都不起作用,要么都与错误(我无法解决)一起使用。
有人知道实现AppWidgets的方法吗?
我正在构建一个自定义启动器。我已经按照Android文档中提到的步骤来托管应用小部件以及浏览默认的Launcher源代码。但是,当我使用意图动作作为AppWidgetManager.ACTION_APPWIDGET_BIND调用startActivityForResult时,即使用户正在接受UI上显示的对话框提示,它也始终返回Activity.RESULT_CANCELED。
这是代码片段
appWidgetManager = AppWidgetManager.getInstance(this);
appWidgetHost = new AppWidgetHost(this, 7772);
int appWidgetId = appWidgetHost.allocateAppWidgetId();
Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
startActivityForResult(pickIntent, REQUEST_PICK);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, " onActivityResult " + requestCode + " res " + resultCode);
if (requestCode == REQUEST_PICK && resultCode == Activity.RESULT_OK)
{
int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
AppWidgetProviderInfo info = appWidgetManager.getAppWidgetInfo(appWidgetId);
boolean hasPermission = appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider);
if (!hasPermission)
{
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, …
Run Code Online (Sandbox Code Playgroud) 这不是Android 应用程序创建两个启动器图标(LAUNCHER
我的清单中没有多个定义)的副本,也不是Android 应用程序创建两个启动器图标而不是一个(设备重启不会删除第二个启动器图标)的副本。
我的 android 应用程序正在创建两个启动器图标,但其中一个似乎来自应用程序本身,而不是任何活动。我已经把我的裁剪AndroidManifest.xml
到最小(加上清理、重建和重新安装),我仍然得到两个图标(在我的 HTC One M8 物理手机和我的 Nexus 5 模拟器上):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".SplashActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
有没有别的在我的清单。
...我定义的应用程序本身是否以某种方式创建了一个图标?或者有没有其他方法让我得到多个启动器图标?
如果我将android:label
和android:icon
功能移到.SplashActivity
定义中,创建的启动器图标之一将替换为默认的小绿色机器人图标。
我正在开发一款能够读出汽车数据的应用程序.
当用户第一次打开它时,他必须选择他驾驶的汽车(这是在MainActivity中).
我想要做的是,用户在打开App时不能总是选择他的车.
在用户选择汽车一次后,应用程序应直接转到他的汽车的汽车数据活动.
你能告诉我一些如何做的想法吗?
我已经在AndroidManifest中写道,MainActivity和这个Car Data Activity是Launcher Activities,但我认为它不会起作用,因为App应该知道哪个Activity应该启动Activity.
请帮帮我一下!
android android-manifest android-activity start-activity android-launcher
我正在编写一个必须保留在平板电脑屏幕上的应用程序,每个人都可以访问.
这意味着只有知道密码的人才能访问平板电脑,而路过的用户只能使用该应用.但是,我被困在主页按钮上.有没有办法改变它?禁用,控制,什么?
我的启动器图标没有出现在我的ActionBar中,尽管设置了android:icon
属性(当我安装应用程序时,启动器出现在我的主屏幕上).注意:我正在使用片段,他们也提供了操作项 - 但这不应该影响主页图标集,对吗?
以下是我的清单中的一些相关代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns="http://schemas.android.com/apk/res/android"
package="com.mywebsite.myapp">
<application
android:name=".MyApp"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
...etc...
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
来自styles.xml的代码:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
来自menu_main.xml的代码,以获得良好的衡量标准:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<!-- Note: my fragments also contribute action items. -->
<item
android:id="@+id/action_about"
android:orderInCategory="100"
android:title="@string/menu_item_about"
app:showAsAction="never" />
</menu>
Run Code Online (Sandbox Code Playgroud)
以及MainActivity.java中的一些代码:
package com.mywebsite.myapp;
import android.support.v7.app.ActionBarActivity;
...etc...
public class MainActivity …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个启动器应用程序,我刚刚添加了一个广播接收器,我将使用它来更新应用程序列表。我最初尝试接收ACTION_PACKAGE_ADDED
,ACTION_PACKAGE_REMOVED
因为它们似乎足以胜任这项工作,但没有一个被解雇,所以我添加了我认为有用的所有其他与包相关的操作,并尝试在活动中注册它们:
val intentFilter = IntentFilter()
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED)
intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED)
intentFilter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED)
intentFilter.addAction(Intent.ACTION_PACKAGE_INSTALL)
intentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED)
val rec = AppsInstallationsReceiver()
registerReceiver(rec, intentFilter)
Run Code Online (Sandbox Code Playgroud)
并体现:
<receiver android:name=".core.installed_apps.AppsInstallationsReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
接收器本身没什么特别的:
class AppsInstallationsReceiver : BroadcastReceiver() {
override fun onReceive(p0: Context?, p1: Intent?) {
//TODO
}
}
Run Code Online (Sandbox Code Playgroud)
事实证明,我只收到PACKAGE_FULLY_REMOVED
并且仅当它在清单中注册时才收到。现在这已经足够好了,但我需要一种方法来知道何时安装新应用程序。由于这是一个启动器应用程序,因此此功能至关重要。为什么我没有收到任何东西?当然,该活动仍然存在于后台,因为它被用作启动器。