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. I need android developers guide in pdf

Hi all

 Where can i get the developers guide in pdf...

-- 

2. Audio file list

I need to acquire my audio file names in my raw folder.
fileList() of Context class doesn't seem to work. It returns null.

private void makeAudioList(){
        String[] audiofiles = this.fileList();
:
:

It tried placing files in the asset folder as well but still the
return is null.

I'm going to create a test application to test a list of audio files
in my res/raw folder.

I'm open in playing from the asset folder but I haven't tried playing
my audio files from there.

I hope somebody could help. m(__)m

Thanks!

-- 

3. spinner question

4. Sound board App

5. Android Market Developer Console Bugs feature

6. Dynamically add an ImageView to a Widget

7. Compile Adwhirl SDK