在Android手机的AppWidget上如何打开一个Activity?
一、onUpdate()函数中
//创建一个Intent对象
Intent intent = new Intent(context,MyActivity.class);
intent.setAction(broadCastString);
//设置pendingIntent的作用
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),R.layout.appwidgetlayout);
//绑定事件
remoteViews.setOnClickPendingIntent(R.id.image_wifi,pendingIntent);
//更新Appwidget
appWidgetManager.updateAppWidget(appWidgetIds,remoteViews);
二、AndroidManifest.xml中注册MyActivity
<activity
android:name="com.example.myappwidget.MyActivity"
android:label="hehe" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
大体的步骤是如此,具体你可以根据自己的要求做出修改