android widget 点击进入应用
package com.ljapps.wifix.ui.provider; import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.RemoteViews; import com.ljapps.wifix.R;
import com.ljapps.wifix.ui.activity.WifiXEntryActivity; /**
* Created by Alter on 16/9/7.
*/
public class WidgetIconProvider extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
for (int i = 0; i < N; i++) {
int appId = appWidgetIds[i];
Intent intent = new Intent(context, WifiXEntryActivity.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId); // Identifies the particular widget...
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
PendingIntent pendIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.layout_widget);
views.setOnClickPendingIntent(R.id.widget_icon, pendIntent);
appWidgetManager.updateAppWidget(appId,views);
}
} @Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:id="@+id/widget_icon"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@drawable/ic_launcher"/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:initialLayout="@layout/layout_widget"
android:minHeight="60dp"
android:minWidth="60dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen|keyguard"></appwidget-provider>
<receiver android:name=".ui.provider.WidgetIconProvider">
<meta-data android:name="android.appwidget.provider"
android:resource="@layout/widget_icon_provider"></meta-data>
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
</receiver>
android widget 点击进入应用的更多相关文章
- Android不规则点击区域详解
Android不规则点击区域详解 摘要 今天要和大家分享的是Android不规则点击区域,准确说是在视觉上不规则的图像点击响应区域分发. 其实这个问题比较简单,对于很多人来说根本不值得做为一篇博文写出 ...
- Android journey3 @点击事件的4种写法
对于android布局中的控件,如Button等会有相应的点击事件去响应它所需要的功能,今天我们就以电话拨号器的代码说明下几种点击事件: package com.itheima.phone; impo ...
- 完美逆向百度手机助手5.0底部菜单栏 - Android Tabhost 点击动画
先看看百度手机助手5.0的样子: 发现他是用一个CustomTabHost.java来实现底部TabHost点击效果的,很漂亮,点击Tab的时候文字会上跑,图片会从底部跑出来的一个小动画. 下面我用自 ...
- Android ImageView 点击更换头像
首先搭建布局 主界面布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" ...
- android widget 开发实例 : 桌面便签程序的实现具体解释和源代码 (上)
如有错漏请不吝拍砖指正,转载请注明出处,很感谢 桌面便签软件是android上经常使用软件的一种,比方比較早的Sticky Note,就曾很流行, Sticky Note的介绍能够參见 http:// ...
- Android Widget 小部件(四---完结) 使用ListView、GridView、StackView、ViewFlipper展示Widget
官方有话这样说: A RemoteViews object (and, consequently, an App Widget) can support the following layout cl ...
- Android编写点击TextView拨打电话
在任何一个电商平台都会有点击了手机号码会拨打出一个电话 那么高如何实现这个功能,我们下来分析下原理 当我们点击了一个电话号码后,会弹出一个Dialog显示是否拨打次电话号码,点击确定拨打号码,点击取消 ...
- Android Widget 开发详解(二) +支持listView滑动的widget
转载请标明出处:http://blog.csdn.net/sk719887916/article/details/47027263 不少开发项目中都会有widget功能,别小瞧了它,他也是androi ...
- java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
Caused by: Java.lang.ClassCastException: Android.widget.TextView cannot be cast to android.widget.Ed ...
随机推荐
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛 A Simple Job
描述 Institute of Computational Linguistics (ICL), Peking University is an interdisciplinary institute ...
- centOS安装Mysql指南
centOS安装Mysql指南 说明:使用操作系统centOS6.4 32位系统:mysql:mysql-5.7.10-linux-glibc2.5-i686.tar.gz; 一.准备 下载mysql ...
- cvs版本控制器
CVS 版本控制器 首先我们要来明确 :为什么要学习CVS •项目开发靠的是一个团队的能力,很少有大中型项目是由个人完成的.对于团队开发来讲---能控制每个人的分工和权限, 可以让多个人同时编辑同 ...
- ggplot2 legend图例的修改
ggplot2中的legend包括四个部分: legend.tittle, legend.text, legend.key, legend.backgroud.针对每一部分有四种处理方式: eleme ...
- 7.Constants and Fields
1.Constants is a symbol that has a never-changing value. its value must be determinable at compile ...
- LINQ 简单用法【1】
LINQ:Language INtegrated Query,语言集成查询. 以下内容演示如何利用LINQ进行增加,修改,删除和查询操作,针对数据库. 首先创建Linq Class. 添加数据库信息, ...
- hdu 1023 卡特兰数+高精度
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- T-SQL JOIN
a表name sex张三 男李四 女 b表name age李四 30王五 23 1 全外连接select a.name,a.sex,b.name,b.agefrom a full outer join ...
- Javascript Object Layout
- 刻录DVD_目录
1.down.52pojie.cn (20160701) (1 in 5) 工具 2.down.52pojie.cn (20160701) (2 in 5) Android VM 6/7 3.down ...