开发者

android widget question

开发者 https://www.devze.com 2023-01-10 13:20 出处:网络
can anybody give example how to开发者_运维知识库 implement click event in appwidget in android ?

can anybody give example how to开发者_运维知识库 implement click event in appwidget in android ?

Thanks


You can use RemoteViews.setOnClickPendingIntent(R.id.view_id, intent) method for handle click event of app-widget. For more information you can refer below link

Click here


Use RemoteViews.setOnClickPendingIntent(R.id.view_id, intent) method. The intent parameter should be a well formed Intent object which would match on of the filters at your manifest file.


        Intent intent = new Intent(context, Activity.class);
        Uri widgetId = Uri.parse("" + appWidgetId); // this line means
        intent.setData(widgetId); // you can send a widget id
        PendingIntent pintent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

        views.setOnClickPendingIntent(R.id.clickButtoninWidget, pintent);
        return views;
0

精彩评论

暂无评论...
验证码 换一张
取 消