Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Issue in Desktop widget click event

Issue in Desktop widget click event

Put your problem here if it does not fit any of the other categories.

Issue in Desktop widget click event

Postby sanjay » Mon May 31, 2010 2:44 pm

Hi,

I need to create a desktop widget. The configuration activity fetch the data from server and place them into local vector.

The widget contains a text area to display the data and up/down button to navigate to adjacent data. I am not able to handle click event on up/buttons.

Following is code snippet I tried for if one click on up/down button the respective text ("up"/"down") will display in text area. but it's not working. :(

Can any one please let me know if this is correct approach or suggest me how to do it.


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.     public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
  3.         Log.d(LOG_TAG, "onUpdate(): ");
  4.  
  5.         for (int appWidgetId : appWidgetIds) {
  6.                
  7.                 //--------------Register the action listener for widget button here
  8.                
  9.                 System.out.println("widget msg in update="+Utility.widget_msg);
  10.                
  11.                 Intent intentup = new Intent(context, ImagesWidgetProvider.class);
  12.                 intentup.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
  13.                 intentup.putExtra("UPDOWN", "up");
  14.                
  15.                 Intent intentdown = new Intent(context, ImagesWidgetProvider.class);
  16.                 intentdown.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
  17.                 intentdown.putExtra("UPDOWN", "down");
  18.                
  19.                 PendingIntent pendingintentup = PendingIntent.getBroadcast(context, 1, intentup, 0);
  20.                 PendingIntent pendingintentdown = PendingIntent.getBroadcast(context, 2, intentdown, 0);
  21.  
  22.                RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.widget);
  23.            
  24.             remoteView.setOnClickPendingIntent(R.id.button_up, pendingintentup);
  25.             remoteView.setOnClickPendingIntent(R.id.button_down, pendingintentdown);
  26.            
  27.             System.out.println("onUpdate called");
  28.             System.out.println("Utility.message1:"+Utility.message1);
  29.             System.out.println("Utility msg_index="+Utility.msg_index);
  30.            
  31.             if(Utility.message1.equals("up"))
  32.             {
  33.                
  34.                 remoteView.setCharSequence(R.id.mytext, "setText", "up button pressed");
  35.             }
  36.             else if (Utility.message1.equals("down"))
  37.             {
  38.                 remoteView.setCharSequence(R.id.mytext, "setText", "down button pressed");
  39.             }
  40.  
  41.             appWidgetManager.updateAppWidget(appWidgetId, remoteView);
  42.  
  43.         }
  44.          super.onUpdate(context, appWidgetManager, appWidgetIds);
  45.     }
  46.  
  47.  //--------------------------------------------------------------------------------------------------------------------------------
  48.  
  49.  public void onReceive(Context context, Intent intent) {
  50.         // v1.5 fix that doesn't call onDelete Action
  51.         final String action = intent.getAction();
  52.        
  53.         if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) {
  54.                 final int appWidgetId = intent.getExtras().getInt(
  55.                 AppWidgetManager.EXTRA_APPWIDGET_ID,
  56.                 AppWidgetManager.INVALID_APPWIDGET_ID);
  57.                 if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
  58.                 this.onDeleted(context, new int[] { appWidgetId });
  59.                 }
  60.         }
  61.                 else
  62.                 {
  63.  
  64.                  
  65.                   if(intent.getAction().equals(AppWidgetManager.ACTION_APPWIDGET_UPDATE)){
  66.                        
  67.                         System.out.println("Intent is having ACTION_APPWIDGET_UPDATE");
  68.                           String msg = "null";
  69.                    
  70.                        
  71.                         try {
  72.                         msg = intent.getStringExtra("UPDOWN");
  73.                              
  74.                         System.out.println("on receive called");
  75.                         System.out.println("VALUE OF UPDOWN:"+msg);
  76.                        
  77.                      
  78.                        
  79.                     if(msg.equals("up")){
  80.                                
  81.                                 Utility.message1="up";
  82.                                
  83.                         }
  84.                        
  85.                         else if(msg.equals("down")){
  86.                                
  87.                                 Utility.message1="down";
  88.                                  
  89.                         }
  90.                        
  91.                        
  92.                         //Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
  93.                            
  94.                         }
  95.                        
  96.                         catch (NullPointerException e) {
  97.                         Log.e("Error", "msg = null");
  98.                         }
  99.                     }
  100.                
  101.                 super.onReceive(context, intent);
  102.                 }
  103.     }
  104.    
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
Parsed in 0.016 seconds, using GeSHi 1.0.8.4
Sanjay Ujjainkar
sanjay
Freshman
Freshman
 
Posts: 2
Joined: Thu Jan 07, 2010 9:52 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 5 guests