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. ViewFlipper & bringChildToFront(View v)

I have this ViewFlipper populated with views via addView(View v). Now,
the simple task is to bring specific (not just next or previous) view
to the top. Looks like bringChildToFront(View v) with a passed
reference to a View should do this. It doesn't, the "top" view doesn't
change.
Plz suggest what am I doing wrong. TIA.
--~--~---------~--~----~------------~-------~--~----~

2. open sms database.

hello.

partA:
i want a simple code example on how to open a database in my android's
local filesystem.
please help cause i ve been really lost here.

partB:
what i want to do is open the sms database and store each received sms
message to a string.
i know that sms messages are stored in : /data/data/
com.android.providers.telephony/databases/mmssms.db

thanks in advance!
--~--~---------~--~----~------------~-------~--~----~

3. orange in R.color ?

4. android-framework [Split the Android screen into two parts and run 2 applications simultaneously on both screen]

5. Dumb question about SMS - what port does a normal text SMS come in...

6. howto access music file properties?

7. Identifying a Phone By A Unique ID?