Hi,
I have wroten a wrong code.
I manage to display the first SMS but not to use my button to go to
next.
I don't manage to keep the words for the pendingIntent and  onRecieve.
this is my code:
public class MySMSwidget extends AppWidgetProvider {
        private int sms_id=0;

        public void  onReceive  (Context  context, Intent  intent){
                if (Intent.ACTION_ATTACH_DATA.equals(intent.getAction()))
                {
                Bundle extra = intent.getExtras();
                sms_id = extra.getInt("Data");
                }
        }

         public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[] appWidgetIds) {
                 Cursor c = 
context.getContentResolver().query(Uri.parse("content://
sms/inbox"), null, null ,null,null);
                 String body = null;
                String number = null;
                String date = null;
                c.moveToPosition(sms_id);
                   body = 
c.getString(c.getColumnIndexOrThrow("body")).toString();
                   number =
c.getString(c.getColumnIndexOrThrow("address")).toString();
                   date = 
c.getString(c.getColumnIndexOrThrow("date")).toString();
                c.close();

                RemoteViews updateViews = new 
RemoteViews(context.getPackageName(),
             R.layout.widget_layout);

                updateViews.setTextColor(R.id.text, 0xFF000000);
                
updateViews.setTextViewText(R.id.text,date+'\n'+number+'\n'+body);
                ComponentName thisWidget = new ComponentName(context,
MySMSwidget.class);
                appWidgetManager.updateAppWidget(thisWidget, updateViews);


                IntentFilter filter = new IntentFilter();
                filter.addAction(Intent.ACTION_ATTACH_DATA);

                RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.widget_layout);
        views.setOnClickPendingIntent(R.id.next, changeData(context));

         }
         private PendingIntent changeData(Context context) {
     Intent Next = new Intent();
     Next.putExtra("Data", sms_id+1);
     Next.setAction(Intent.ACTION_ATTACH_DATA);

     return(PendingIntent.getBroadcast(context,
        0, Next, PendingIntent.FLAG_UPDATE_CURRENT));
  }

}
please help!
Just want my button to dysplay next sms!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to