Unable to launch an activity from an AppWidget

by Karl Smith » Fri, 20 May 2011 09:53:37 GMT


Sponsored Links
 I have this code setup in my app widget and I have listed the activity
it should launch below. I can't for the life of me get the activity to
launch when the button is clicked. Nothing happens when I click on it.


public class MyAppWidget extends AppWidgetProvider
{
        public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[] appWidgetIds)
        {
        RemoteViews remoteViews = new
RemoteViews(context.getPackageName(), R.layout.main);


    Intent intent = new Intent(context, EditActivity.class);
                PendingIntent pendingIntent =
PendingIntent.getActivity(context, 0, intent,
Intent.FLAG_ACTIVITY_NEW_TASK);
 
remoteViews.setOnClickPendingIntent(R.id.btnEditConfiguration,
pendingIntent);

                appWidgetManager.updateAppWidget(thisWidget,
remoteViews);
            }
}

 public class EditActivity extends Activity
    {
         public void onCreate(Bundle savedInstanceState)
            {
                super.onCreate(savedInstanceState);
 
setContentView(R.layout.configure);
            }
    }

-- 



Unable to launch an activity from an AppWidget

by Karl Smith » Fri, 20 May 2011 09:53:38 GMT


 I have this code setup in my app widget and I have listed the activity
it should launch below. I can't for the life of me get the activity to
launch when the button is clicked. Nothing happens when I click on it.


public class MyAppWidget extends AppWidgetProvider
{
        public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[] appWidgetIds)
        {
public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[] appWidgetIds)
    {
        RemoteViews remoteViews = new
RemoteViews(context.getPackageName(), R.layout.main);


    Intent intent = new Intent(context, EditActivity.class);
                PendingIntent pendingIntent =
PendingIntent.getActivity(context, 0, intent,
Intent.FLAG_ACTIVITY_NEW_TASK);
 
remoteViews.setOnClickPendingIntent(R.id.btnEditConfiguration,
pendingIntent);

                appWidgetManager.updateAppWidget(thisWidget,
remoteViews);
            }
}

 public class EditActivity extends Activity
    {
         public void onCreate(Bundle savedInstanceState)
            {
                super.onCreate(savedInstanceState);
 
setContentView(R.layout.configure);
            }
    }

-- 


Sponsored Links


Re: Unable to launch an activity from an AppWidget

by Nikolay Elenkov » Fri, 20 May 2011 10:04:06 GMT


 


Are you updating the right widget?
Is btnEditConfiguration visible/enabled?
Does the Activity work when started from launcher?
Any suspicious messages in logcat?

-- 



Other Threads

1. Pilih mana antara sgs, nexus s, atau dhd?

Bingung nech, mohon petunjuk dr suhu2 yg gentayangan dsini?

Hehe cip :)
from cm 6 a8.3

-- 
===============

2. App crashing with the exception View not attached to Window manager

Hi,

In my application, I am running custom progress bar at the time of
data fetching(data is getting fetched using async task and progress
bar is also getting started in the onpreExecute function of the
asyncTask which is getting dismissed by onPostExecute) . If user
change the orientation at the time of fetching and onPostExecute get
called after orientation change, my application is crashing.

Problem is this that progress bar is not attached to the window
manager. I am not sure how to do that.

My queries are:
1. How can i attach progress bar with window manager.
2. How to stop async task at the time of orientation change and how to
stop webrequest call, if orientation is getting changed.
3. Whats the life cycle of activity at the time of orientation change.
I know that it will again call onCreate but will it call onStop and
onDestroy for the previous orientation.
4. What are the steps we should take care for the orientation change.

Please help.

-- 

3. drawable in xhdpi not getting picked up

4. Sony Mylo 2 - other mobile OS ?

5. ADT lauout designer D&D is a mega-disaster...

6. Security enforcement

7. An interesting architecture question for xml resources