OK anyone that can help.


Last Updated:

  1. justin241982

    justin241982 Member This Topic's Starter

    Joined:
    Oct 21, 2010
    Messages:
    10
    Likes Received:
    0
    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.
     

    Advertisement
  2. justin241982

    justin241982 Member This Topic's Starter

    Joined:
    Oct 21, 2010
    Messages:
    10
    Likes Received:
    0
    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.
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      33.1 KB
      Views:
      6
  3. justin241982

    justin241982 Member This Topic's Starter

    Joined:
    Oct 21, 2010
    Messages:
    10
    Likes Received:
    0
    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?
     
  4. AlbertPucciani

    AlbertPucciani Well-Known Member

    Joined:
    Oct 2, 2010
    Messages:
    71
    Likes Received:
    8
    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 (Text):
    1.  
    2. LinearLayout layout = (LinearLayout)this.findViewById(R.id.my_layout);
    3. layout.setOnClickListener(new OnClickListener() {
    4.    public void onClick(View v) {
    5.       // Open the Menu
    6.       MyWidgetProvider.this.openOptionsMenu();
    7.    }
    8. });
    9.  
    Then in the WidgetProvider, you'd need some code kinda like this:

    Code (Text):
    1.  
    2.  
    3.     public final static int MENU_ID_1 = 1;
    4.     public final static int MENU_ID_2 = 2;
    5.     public final static int MENU_ID_3 = 3;
    6.  
    7.     @Override
    8.     public boolean onCreateOptionsMenu(Menu menu) {
    9.         menu.add(0, MENU_ID_1, 1, "Menu Item 1");
    10.         menu.add(0, MENU_ID_2, 3, "Menu Item 2");
    11.         menu.add(0, MENU_ID_3, 2, "Menu Item 3");
    12.        
    13.         return super.onCreateOptionsMenu(menu);
    14.     }
    15.  
    16.    @Override
    17.     public boolean onOptionsItemSelected(android.view.MenuItem item) {
    18.         AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
    19.        
    20.         switch (item.getItemId()) {
    21.  
    22.         case MENU_ID_1: {
    23.             // Do something useful here
    24.             break;
    25.         }
    26.  
    27.         case MENU_ID_2: {
    28.             // Do something useful here
    29.             break;
    30.         }
    31.  
    32.         case MENU_ID_3: {
    33.             // Do something useful here
    34.             break;
    35.         }
    36.  
    37.         }
    38.     }
    39.  
    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
     
  5. justin241982

    justin241982 Member This Topic's Starter

    Joined:
    Oct 21, 2010
    Messages:
    10
    Likes Received:
    0
    [/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.:)
     
  6. AlbertPucciani

    AlbertPucciani Well-Known Member

    Joined:
    Oct 2, 2010
    Messages:
    71
    Likes Received:
    8
    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.
     

Share This Page

Loading...