Add back widget, fix implicit Intent

This commit is contained in:
yuhan6665
2020-06-05 22:42:43 -04:00
parent 6577c46a31
commit ef9e0cc0d2
2 changed files with 12 additions and 11 deletions

View File

@@ -93,16 +93,16 @@
android:value="true" />
</service>
<!--<receiver android:name=".receiver.WidgetProvider">-->
<!--<meta-data-->
<!--android:name="android.appwidget.provider"-->
<!--android:resource="@xml/app_widget_provider" />-->
<!--<intent-filter>-->
<!--<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />-->
<!--<action android:name="com.v2ray.ang.action.widget.click" />-->
<!--</intent-filter>-->
<!--</receiver>-->
<receiver android:name=".receiver.WidgetProvider"
android:process=":RunSoLibV2RayDaemon">
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/app_widget_provider" />
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="com.v2ray.ang.action.widget.click" />
</intent-filter>
</receiver>
<service
android:name=".service.QSTileService"

View File

@@ -20,7 +20,8 @@ class WidgetProvider : AppWidgetProvider() {
super.onUpdate(context, appWidgetManager, appWidgetIds)
val remoteViews = RemoteViews(context.packageName, R.layout.widget_switch)
val intent = Intent(AppConfig.BROADCAST_ACTION_WIDGET_CLICK)
val intent = Intent(context, WidgetProvider::class.java)
intent.setAction(AppConfig.BROADCAST_ACTION_WIDGET_CLICK)
val pendingIntent = PendingIntent.getBroadcast(context, R.id.layout_switch, intent, PendingIntent.FLAG_UPDATE_CURRENT)
remoteViews.setOnClickPendingIntent(R.id.layout_switch, pendingIntent)