Frage

I was thinking if there is a way to add an item in Quick Settings Panel in android ? I have an app called Mirror by Koushik Dutta that does the same. It adds an item in Quick Settings panel. I decompiled the app and saw that he's moving the apk to /system/priv-app . That's it. Nothing's related to adding an item in Quick Settings Toggle. I know it'll require root access (just a college project). Please if anyone has any idea how it can be done, it would be really helpful.

War es hilfreich?

Lösung 4

Koushik Dutta didn't add a new quick settings tile. The "Cast Screen"-Tile is implemented by the android system and appears sometimes. It's a shortcut to the "cast screen"-menu in system settings. Koush added new options for this menu (i don't know if there's an open api or if he needs the root permission for that) and now, the tile is always displayed because there's always content.

To answer your question: No, without system modifications with root, you can't add tiles to the android quick settings. (Edit: I haven't read that you'd also use root. So, you can't add tiles easily and the mirror application by Koushik Dutta doesn't do that, too.)

PS: It isn't because of CyanogenMod, because I use stock android and the app works, too.

Update 2019-08-08: With Android N, there's an official API to add custom quick setting tiles (see Sam's answer).

Andere Tipps

Use the Android N tile API

Custom quick settings can be created in Android N using the tile API. Just make a class that inherits from TileService and add it to the manifest.

Here's the example given in the TileService documentation:

<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>

Recent versions of CyanogenMod 12.1 support this through the 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;
    }
}

The quick settings tiles in Android 4.4 are all hardcoded. Here's a link to the source.

Even with root, the only way to change this would be patching system jars/apks.

The support for Mirror might be added by Cyanogenmod, have you tried if it works on any other ROM?

Edit: Here's a feature request for a quick settings api: https://code.google.com/p/android/issues/detail?id=42616

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top