admin管理员组文章数量:1405860
I've followed everything is there on how to create an Android quick settings tile and on my end nothing seems to work. My tile doesn't seem to appear on the custom tiles.
What is the problem with my source code? I've tested this app on different smartphones from, Samsung, Pixels, Vivo and I can't seem to see my quick settings tile on the add custom tiles section.
Here's my service class
package quick_settings_tile;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.util.Log;
import android.widget.Toast;
public class QuickTileService extends TileService {
// Called when the user adds your tile.
@Override
public void onTileAdded() {
super.onTileAdded();
try {
// Existing onClick code
Tile tile = getQsTile();
tile.setState(Tile.STATE_ACTIVE);
tile.updateTile();
Log.d("QuickTileService", "Tile added");
} catch (Exception e) {
Log.e("QuickTileService", "Crash: " + e.getMessage());
}
}
// Called when your app can update your tile.
@Override
public void onStartListening() {
super.onStartListening();
try {
Tile tile = getQsTile();
tile.setState(Tile.STATE_ACTIVE);
tile.updateTile();
Log.d("QuickTileService", "Tile listening");
} catch (Exception e) {
Log.e("QuickTileService", "Crash: " + e.getMessage());
}
}
// Called when the user taps on your tile in an active or inactive state.
@Override
public void onClick() {
super.onClick();
try {
// Existing onClick code
Tile tile = getQsTile();
Log.d("QuickTileService", "Clicked Label: " + tile.getLabel());
Toast.makeText(this, "Hello, we are almost there!!!!!!!!!!!!", Toast.LENGTH_SHORT).show();
getQsTile().updateTile();
} catch (Exception e) {
Log.e("QuickTileService", "Crash: " + e.getMessage());
}
}
// Called when the user removes your tile.
@Override
public void onTileRemoved() {
super.onTileRemoved();
try {
// Existing onClick code
Log.d("QuickTileService", "Service removed");
} catch (Exception e) {
Log.e("QuickTileService", "Crash: " + e.getMessage());
}
}
@Override
public void onCreate() {
super.onCreate();
try {
// Existing onClick code
Log.d("QuickTileService", "Service created");
} catch (Exception e) {
Log.e("QuickTileService", "Crash: " + e.getMessage());
}
}
}
My Android manifest
<manifest xmlns:android=";
xmlns:tools=";>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Wire"
tools:targetApi="31">
<activity
android:name="receipts.ReceiptActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="quick_settings_tile.QuickTileService"
android:label="Pay bill"
android:icon="@drawable/white_qr_code_scanner"
android:exported="true"
android:permission="android.permission.BIND_QUICK_SETTINGS">
<meta-data android:name="android.service.quicksettings.ACTIVE_TILE"
android:value="true" />
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
</application>
</manifest>
I tried everything mentioned on the tutorials online. On my end, when I test the application, I don't see the result. Like seeing the quick settings tile.
I've followed everything is there on how to create an Android quick settings tile and on my end nothing seems to work. My tile doesn't seem to appear on the custom tiles.
What is the problem with my source code? I've tested this app on different smartphones from, Samsung, Pixels, Vivo and I can't seem to see my quick settings tile on the add custom tiles section.
Here's my service class
package quick_settings_tile;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.util.Log;
import android.widget.Toast;
public class QuickTileService extends TileService {
// Called when the user adds your tile.
@Override
public void onTileAdded() {
super.onTileAdded();
try {
// Existing onClick code
Tile tile = getQsTile();
tile.setState(Tile.STATE_ACTIVE);
tile.updateTile();
Log.d("QuickTileService", "Tile added");
} catch (Exception e) {
Log.e("QuickTileService", "Crash: " + e.getMessage());
}
}
// Called when your app can update your tile.
@Override
public void onStartListening() {
super.onStartListening();
try {
Tile tile = getQsTile();
tile.setState(Tile.STATE_ACTIVE);
tile.updateTile();
Log.d("QuickTileService", "Tile listening");
} catch (Exception e) {
Log.e("QuickTileService", "Crash: " + e.getMessage());
}
}
// Called when the user taps on your tile in an active or inactive state.
@Override
public void onClick() {
super.onClick();
try {
// Existing onClick code
Tile tile = getQsTile();
Log.d("QuickTileService", "Clicked Label: " + tile.getLabel());
Toast.makeText(this, "Hello, we are almost there!!!!!!!!!!!!", Toast.LENGTH_SHORT).show();
getQsTile().updateTile();
} catch (Exception e) {
Log.e("QuickTileService", "Crash: " + e.getMessage());
}
}
// Called when the user removes your tile.
@Override
public void onTileRemoved() {
super.onTileRemoved();
try {
// Existing onClick code
Log.d("QuickTileService", "Service removed");
} catch (Exception e) {
Log.e("QuickTileService", "Crash: " + e.getMessage());
}
}
@Override
public void onCreate() {
super.onCreate();
try {
// Existing onClick code
Log.d("QuickTileService", "Service created");
} catch (Exception e) {
Log.e("QuickTileService", "Crash: " + e.getMessage());
}
}
}
My Android manifest
<manifest xmlns:android="http://schemas.android/apk/res/android"
xmlns:tools="http://schemas.android/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Wire"
tools:targetApi="31">
<activity
android:name="receipts.ReceiptActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="quick_settings_tile.QuickTileService"
android:label="Pay bill"
android:icon="@drawable/white_qr_code_scanner"
android:exported="true"
android:permission="android.permission.BIND_QUICK_SETTINGS">
<meta-data android:name="android.service.quicksettings.ACTIVE_TILE"
android:value="true" />
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
</application>
</manifest>
I tried everything mentioned on the tutorials online. On my end, when I test the application, I don't see the result. Like seeing the quick settings tile.
Share edited Mar 8 at 12:38 Mark Rotteveel 110k229 gold badges156 silver badges224 bronze badges asked Mar 6 at 19:16 Jim The CreatorJim The Creator 32 bronze badges 1- Please trim your code to make it easier to find your problem. Follow these guidelines to create a minimal reproducible example. – Community Bot Commented Mar 6 at 21:18
1 Answer
Reset to default 0Change the name of the permission from
android:permission="android.permission.BIND_QUICK_SETTINGS"
to:
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
as defined in TileService
本文标签: javaHow can I implement Android quick settings tile using Android StudioStack Overflow
版权声明:本文标题:java - How can I implement Android quick settings tile using Android Studio? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744954478a2634274.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论