我在想是否有办法在Android的快速设置面板中添加项目?
我有一个名为Mirror
的应用程序由Koushik Dutta做同样的事情。它在“快速设置”面板中添加了一个项目我反编译应用程序,看到他正在将apk移动到/ system / priv-app。
而已。没有什么与在快速设置切换中添加项目有关。
我知道它需要root访问权限(只是一个大学项目)。如果有人知道如何做到这一点,那将非常有用。
答案 0 :(得分:4)
可以使用tile API在Android N中创建自定义快速设置。只需创建一个继承自TileService
的类,并将其添加到清单中。
以下是TileService
文档中提供的示例:
<service
android:name=".MyQSTileService"
android:label="@string/my_default_tile_label"
android:icon="@drawable/my_default_icon_label"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
答案 1 :(得分:2)
CyanogenMod 12.1的最新版本通过CyanogenMod Platform SDK:
支持此功能public void publishTile() {
if (supportsCustomTiles()) {
Intent receiver = new Intent(context, TileClickedReceiver.class);
PendingIntent clickIntent = PendingIntent.getBroadcast(
context,
0,
receiver,
PendingIntent.FLAG_CANCEL_CURRENT
);
CustomTile tile = new CustomTile.Builder(context)
.setIcon(R.drawable.tile_icon)
.setLabel("Test Tile")
.setOnClickIntent(clickIntent)
.build();
CMStatusBarManager
.getInstance(context)
.publishTile(1234, tile);
}
}
private boolean supportsCustomTiles() {
try {
Class.forName("cyanogenmod.app.CustomTile");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
答案 2 :(得分:1)
Android 4.4中的快速设置磁贴都是硬编码的。 Here's a link to the source
即使使用root,更改此功能的唯一方法是修补系统jar / apks。
Cyanogenmod可能会添加对Mirror
的支持,如果它适用于任何其他ROM,你试过吗?
编辑:以下是快速设置API的功能请求:https://code.google.com/p/android/issues/detail?id=42616
答案 3 :(得分:1)
Koushik Dutta没有添加新的快速设置磁贴。 “Cast Screen”-Tile由android系统实现,有时会出现。它是系统设置中“投射屏幕”菜单的快捷方式。 Koush为这个菜单添加了新选项(我不知道是否有开放api或者他是否需要root权限)现在,因为总是有内容,所以会一直显示tile。
回答你的问题:不,如果没有使用root进行系统修改,你就无法在android快速设置中添加磁贴。 (编辑:我还没有看到你也使用root。因此,你不能轻易添加磁贴,而Koushik Dutta的镜像应用也不会这样做。)
PS:这不是因为CyanogenMod,因为我使用股票android和应用程序也可以。