• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps OK anyone that can help.

I just need someone to point me in the right direction to add the ability to a widget that can make it open any application that you may have installed on your device.
I am totally new to this but since I like the android devices so much I wanna try to develop. I have made a few live wallpapers already and that went good.

Pretty much what I want is after I create the widget I want to be able to tap the widget and have it open a menu much like the one you see when you long press on the background, so you can make it when you press the widget after its configured and it opens whatever you have pointed it at?

Some code that I could slap in and learn from would be great since I dont know to much code yet besides what it took to make the live wallpapers but any pointing in the right direction would be greatly appreciated.
 
This is the menu I would like to be able to make my widget access. Is this possible? Can it use the system itself to set its function?

Seriously I have been searching for this for three days through so much code and reading that I think my head is gonna explode, I really need some help here. Its hard to decipher what I need to know for what I want to do and what doesnt relate at all when I am reading the tutorials past the very basics.
 

Attachments

  • 1.jpg
    1.jpg
    33.1 KB · Views: 124
Really 101 people have read this and not even one person could stop for a second and either call me a moron or throw a link on here. Isnt this what forums are for?
 
Hi,

I've never made a Widget before, but assuming that you it's the similar to the Activity based approach that I'm familiar with it's something like this in your onUpdate method:

Code:
LinearLayout layout = (LinearLayout)this.findViewById(R.id.my_layout);
layout.setOnClickListener(new OnClickListener() {
   public void onClick(View v) {
      // Open the Menu
      MyWidgetProvider.this.openOptionsMenu();
   }
});

Then in the WidgetProvider, you'd need some code kinda like this:

Code:
    public final static int MENU_ID_1 = 1;
    public final static int MENU_ID_2 = 2;
    public final static int MENU_ID_3 = 3;

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    	menu.add(0, MENU_ID_1, 1, "Menu Item 1");
    	menu.add(0, MENU_ID_2, 3, "Menu Item 2");
    	menu.add(0, MENU_ID_3, 2, "Menu Item 3");
    	
    	return super.onCreateOptionsMenu(menu);
    }

   @Override
    public boolean onOptionsItemSelected(android.view.MenuItem item) {
		AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
		
    	switch (item.getItemId()) {

        case MENU_ID_1: {
            // Do something useful here
            break;
        }

        case MENU_ID_2: {
            // Do something useful here
            break;
        }

        case MENU_ID_3: {
            // Do something useful here
            break;
        }

        }
    }

You're probably not getting a lot of replies because most devs don't make widgets, I had to spend 5 minutes (thats a lot to ask of most people) just to understand *basic* widget development. You'll have to figure out exactly how to convert my code for an Activity to your Widget. Good Luck!


P.S., Almost forgot, you're a moron :p
 
[/QUOTE]most forgot, you're a moron :p[/QUOTE]

LMFAO. Thanks man appreciate the response, the only reason I want to make the widgets is so people can add to the themes they like with customizable objects that can be set for anything like a little goblin ripping out of the corner of your screen that you can tap to make a phone call and stuff like that. Again you rock thanks.:)
 
Cool idea, make the Android more customizable. Maybe you could even alter the System theme some how so that the Home Screen looks different too. Just a thought.

If you run into any issues, feel free to ask as I'm subscribed to this thread.
 
Back
Top Bottom