Android javaseröapp Widget
Android javaseröapp Widget* Widget £;ö~~~ózälanguçpendingintent ° íremoteviews £.PendingIntent ö÷ ª Ó À réööö ×à Ã æ ³ Ð µ ¿É Ò Ó órāzöööintent · zookeeper £ ******************************************************** úorþ ¸ öç ço ¢ Í Ò» ö ö¹ ã ² £ ******************» ö öservice *****************************
RemoteViews µä×ó Ó £° Ò Î À »? ø Ø {£%%²» ärírâ ¨ Õ ý %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% £ ;********************************************************************** ~úranâ ¸ ögráöð Ó ****öö?app Widget?
Â Ã Î Ò Ç çà 'hangzhou' úâ {£ **************************************************** É Ï ö ö~~{µäpendinginetnt µämöööööö~~£°part 1 £° {{{}» Ö ö~â µäactivity £;» part 2 £° · ******************************************
Ö?###%%%%%%%mainactivity. java %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Package com. example. appwidget;
Import android. OS. Bundle;
Import android. app. Activity;
Import android. view. Menu;
Public class MainActivity extends Activity {
@ Override
Protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
}
@ Override
Public boolean onCreateOptionsMenu (Menu menu ){
// Inflate the menu; this adds items to the action bar if it is present.
GetMenuInflater (). inflate (R. menu. main, menu );
Return true;
}
}
Appwidget ×à too many other than limit µäà AppWidgetProviderTest. java £°
Package com. example. appwidget;
Import android. app. PendingIntent;
Import android. appwidget. AppWidgetManager;
Import android. appwidget. AppWidgetProvider;
Import android. content. ComponentName;
Import android. content. Context;
Import android. content. Intent;
Import android. widget. RemoteViews;
Public class AppWidgetProviderTest extends AppWidgetProvider {
// ×Ô ¨ Ò» ö öaction ¿
Private final String USER_ACTION = "com. example. appwiet. USER_ACTION ";
// Micro± APP widget limit Micro?
@ Override
Public void onDeleted (Context context, int [] appWidgetIds ){
// TODO Auto-generated method stub
Super. onDeleted (context, appWidgetIds );
System. out. println ("onDeleted ()");
}
// μ ± × î ° ónó» ö öapp widget Ê μ À ý ±» É ¾ ³ ý ± £;» áµ÷ ónó Ã
@ Override
Public void onDisabled (Context context ){
// TODO Auto-generated method stub
Super. onDisabled (context );
System. out. println ("onDisabled ()");
}
// μ ± µúgou» ö öapp widget Ê µà ý ±» ''¨ ± £;» áµ÷ óó Ã
@ Override
Public void onEnabled (Context context ){
// TODO Auto-generated method stub
Super. onEnabled (context );
System. out. println ("onEnabled ()");
}
// The Ó Ê app has been transferred to µäë Ó Ð %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ Override
Public void onReceive (Context context, Intent intent ){
// TODO Auto-generated method stub
System. out. println ("onReceive ()");
// ± È Ï Â £%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% success, Ç Ò ü Ð Â ×à Ã Ø ¼ þ
If (USER_ACTION.equals (intent. getAction ())){
System. out. println ("onReceive -->" + USER_ACTION );
//» N'{remoteviews {{}ó
RemoteViews remoteView = new RemoteViews (context. getPackageName (), R. layout. appwidget_provider );
// Ü U Ð Â ×à à æ TextView Ø ¼ þ µätext
RemoteView. setTextViewText (R. id. myText, "onReceive ");
AppWidgetManager appWidgetManager = AppWidgetManager. getInstance (context );
ComponentName componentName = new ComponentName (context, AppWidgetProviderTest. class );
AppWidgetManager. updateAppWidget (componentName, remoteView );
} Else {
// Μó óó ¸ À fià µä½ ¨
Super. onReceive (context, intent );
}
}
// Ú úµ½ 'ö ö¸ ¨ %%**************************** App widget optional µà {± £;» áµ÷ Ó Ã '{· }·?
@ Override
Public void onUpdate (Context context, AppWidgetManager appWidgetManager,
Int [] appWidgetIds ){
// TODO Auto-generated method stub
Super. onUpdate (context, appWidgetManager, appWidgetIds );
System. out. println ("onUpdate ()");
// Please refer to the following links for more information:» ö öapp widget µ μ? äöööapp widget {µà ý Ó óó Ò» ö ö¶ Ó ózäid
For (int I = 0; I <appWidgetIds. length; I ++ ){
System. out. println ("appWidgetIds -->" + appWidgetIds [I]);
// ''¨ Ò» ö öintent ¶ Ï ó
Intent intent = new Intent ();
// Part 1 £° pendingIntent Ó À ''contains some unknown details» ö öð  µäactivity
/* Intent. setClass (context, MainActivity. class );
// Ê Ó ó getActivity · activities · ''¨ Ò» ö öpendingintent has been added to ó ó£;;%'' then has been transferred to Ó óózúrúø ø × ª activity £;{« intent '{° ü ¸ ø pendingIntent
PendingIntent pendingIntent = PendingIntent. getActivity (context, 0, intent, 0 );
*/
// End part1
// Part 2 £° pendingIntent Ó Ã À '· ¢ Ë íí» ö ö¹ ã ² ¥
// Maid action
Intent. setAction (USER_ACTION );
// Ê Ó ó~getbroadcast () · videos · ''' ¨» ö öpendingintent ~~ó ó
PendingIntent pendingIntent = PendingIntent. getBroadcast (context, 0, intent, 0 );
// End part2
// ''¨ ¨» ~Öremoteviews ~~~~ó
RemoteViews remoteView = new RemoteViews (context. getPackageName (), R. layout. appwidget_provider );
// RemoteViews has been added to the shortlisted folder.
RemoteView. setOnClickPendingIntent (R. id. WidgetButton, pendingIntent );
AppWidgetManager. updateAppWidget (appWidgetIds [I], remoteView );
}
}
}
Ö÷ ³ Ì ò %% ************************************************************** Xmlns: tools = "http://schemas.android.com/tools"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
Android: paddingBottom = "@ dimen/activity_vertical_margin"
Android: paddingLeft = "@ dimen/activity_horizontal_margin"
Android: paddingRight = "@ dimen/activity_horizontal_margin"
Android: paddingTop = "@ dimen/activity_vertical_margin"
Tools: context = ". MainActivity">
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/hello_world"/>
App widget maid ~~ö~ä~~~~~~appwidget _ provider. xml £° £° **************************
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
Android: orientation = "vertical">
Android: id = "@ + id/myText"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "welcome appwidget"
Android: background = "# ff0000"
/>
Android: id = "@ + id/WidgetButton"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "Widget Button"
/>
Appwidget_provider μ äô ª ý ¾ µ µäî þ appwidget _ provider_info.xml £°
Xmlns: android = "http://schemas.android.com/apk/res/android"
Android: minWidth = "180dp"
Android: minHeight = "40dp"
Android: updatePeriodMillis = "1000"
Android: initialLayout = "@ layout/appwidget_provider"
>
AndroidManifest. xml Ä ää £°
Package = "com. example. appwidget"
Android: versionCode = "1"
Android: versionName = "1.0" type = "codeph" text = "/codeph">
Android: minSdkVersion = "8"
Android: targetSdkVersion = "17"/>
Android: allowBackup = "true"
Android: icon = "@ drawable/ic_launcher"
Android: label = "@ string/app_name"
Android: theme = "@ style/AppTheme">
Android: name = "com. example. appwidget. MainActivity"
Android: label = "@ string/app_name">
Android: name = "com. example. appwidget. AppWidgetProviderTest">
Android: name = "android. appwidget. provider"
Android: resource = "@ xml/appwidget_provider_info"/>
Ê μ Ï öµäð § ¹ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Ö÷ ³ Ð ò ç £°
<Example · example "http://www.bkjia.com/kf/ware/vc/" target = "_ blank" class = "keylink"> example = "" alt = "\">
App widget ********************************************************************** ********************************************************** many widgets have been added to the original architecture of the app, such as £ *******************************************************
{0} {0} {0} {0} {0} {0} {0} {0} {0} {0} Ä äwidget öð µätextview Ø too many µätext £20.µ;» ° óµä§ § ~~~~~â £°