Why is it that whenever there is good news, bad news is soon to follow?
Always wondered why that happens. Never had a good reason I could accept though.
Anyway, the good news! I’ve successfully created the widget’s layout. Appearance looks good. Well… looks decent. The widget looks a bit flat. Doesn’t have the 3Dish effect that the other widgets from Google or other companies have. I might need to play around the gradient settings and shadows and that kind of stuff tomorrow. But for now, I got the design created, layout looked pretty nice. This is still for the 3×1 widget of course. I’ve also successfully made it be able to launch the full list.
That took a LOT of trouble. I couldn’t understand why it wasn’t able to launch. For activities, you could do it very easily by creating an intent and calling startActivity(intent) or startActivityForResult(intent), but for app widgets, we had to use PendingIntents. Also, we’re not able to use startActivity or startActivityForResult. I had NO idea why it wasn’t working. Everything looked fine. I tested it out a lot of times, but no use, it wouldn’t work.
Originally, code was:
intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); remoteView.setOnClickPendingIntent(R.id.position2, pendingIntent);
That code was supposed to create an intent of the Main Activity I set in the manifest.xml file.
Turns out, I wasn’t supposed to use PendingIntent.getBroadcast(context, 0, intent3, PendingIntent.FLAG_UPDATE_CURRENT); I was also, supposed to add in a ComponentName.
Correct code is:
Intent intent = new Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(new ComponentName("packageName","className")); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); remoteView.setOnClickPendingIntent(R.id.position2, pendingIntent);
Well, that sure took a long time to fix. But good thing is, its fixed.
Now for the bad news, I still have to think of a icon, a good name, fix up the widget appearance, do the Pro version of the project, and fix up my sleeping schedule.
Wow, its 3:36am! Definitely need to sleep! If all goes well, I should be able to finish everything tomorrow! =]