Android :: Make Different Instances Of A Widget Behave Different Based On Their AppWidgetId
Oct 5, 2009
I am developing a simple widget which has a couple of buttons in its layout.
Before the widget gets added, the configuration activity is displayed, where the user can choose if the widget makes any sounds when the buttons get pressed or not.
Thus, a user can put two instances of the widget, one where he chose sound to be activated and another where he chose the opposite. However, I can not seem to be able to reproduce the expected behavior (that one reproduces sound and the other doesn't).
The buttons' behavior varies according to the flags specified to the PendingIntent:
- FLAG_UPDATE_CURRENT seems to override the previous intent/setting - no flags (0x00) seems to ignore any intent/setting after the first instance of the widget is put.
What I want to do: I want to be able to configure different instances of the same widget to behave in a different way, according to what the user specified in the configuration activity. I am attempting to do this with the help of the appWidgetId of each instance:
I have tried the following when assigning an action to the click of the button:
CODE:.................
This results in the first widget acting properly (The IDs printed in logcat are as expected) When adding a second widget, however, the first widget starts reporting the second widget's appWidgetId in its onReceive(), when it previously did no such thing. (because of the FLAG_UPDATE_CURRENT, I guess)
How can one make different instances behave in a different way? Is there a way to do this with the help of the appWidgetId?
I have elaborated a widget application for the purpose of debugging this problem which tries to be minimal, while reproducing the (un) desired behavior: http://www.2shared.com/file/8243059/b6519584/IntentTesttar.html
View 5 Replies
Nov 11, 2009
I had an iPhone until I got the Droid yesterday. I absolutely love the Droid and would never go back to an iPhone. However, the iPhone integrated well with my car radio, which has a USB port. The radio can play from USB, but then I have to navigate my folders from the radio. It's difficult, unintuitive, and less functional than playing music directly from the phone.
Is there an app that would fake out a connected device to make it think the Droid was an iPhone, and would let me use the Droid's music player interface to play music through the USB?
View 7 Replies
View Related
Jun 18, 2009
If anyone can help me with some information if there is a way to make an application on Android Dev Phone ask for permissions, like it does on G1. When I install an application on ADP, I only get the message "no permissions required", is there a way to make the ADP behave like a G1 phone?
View 7 Replies
View Related
Jan 26, 2010
I have a widget that acts as a launcher on the home screen. How can I make it behave like a launcher icon?
I use this layout for portrait:
CODE:................
And this is the background selector:
CODE:................
This way if I use the DPAD the widget is focusable but the click doesn't work. The touch still works but the widget is not displayed as focused.
View 2 Replies
View Related
May 31, 2010
I have a big background image for my views's background, which also can be tiled (it's repeadable). When switching from one Activity to another i want the background to behave like on the homescreen (the background moves only a bit, but the foreground moves one screen with). Is this possible and how? Here is my current background definition:.............
View 1 Replies
View Related
Jul 22, 2009
I need to correctly be able to differentiate between emulator instances. I know it's easily done with real devices. With real devices, you can use getDeviceId or getLine1Number from TelephonyManager. With emulators, all the instances have the same device id, same subscriber id, and same line1 number. Is there a way to differentiate them? Using NetworkInfo, I can call the toString method and I get my ip and the port on the computer. The problem with that is that the port is always different. I would like something more stable. Like when you use "adb devices" in command line. Emulator #1 is almost always "emulator-5556" and emulator#2 is almost always "emulator-5554". Is there a way to get the same info I get from "adb devices" in my code? If not, is it possible to use a command line parameter to force the emulator to use a certain phone number?
View 3 Replies
View Related
May 17, 2009
I want an EditText to look like TextView but still behave like EditText. I've tried applying TextView style to my EditText in my layout.xml file, like this:
CODE:............
But I get an error within xml editor: "Error: No resource found that matches the given name (at 'style' with value '@android:style/ Widget_TextView')." It is strange because @android:style/ Widget_TextView definitively exists - I double checked it in code via android.R.style.Widget_TextView. Another strange thing is that I don't get android:style offered in the xml editor while typing? There is android:id, android:text and everything else.. but not android:style?
I consider the hard way (making EditText look like TextView) to be: extending EditText and overriding it's onDraw method.
View 9 Replies
View Related
May 3, 2010
OK, here goes my first post.
I have the calendar syncing with my gmail calendar, which has multiple calendars inside (mine, my wifes, ours, baseball schedule, cavs schedule, etc..)
I also have the stock "mail" (not Gmail) application syncing with my exchange at work.
Since I got 7 home screens to work with, I wanna put my Gmail calendar on home screen #1, and my exchange calendar on home-screen #7. Sort of a seperation of home and work
So I put the stock widget on home-screen#1, and again on home-screen#7. But a widget is basically just a frontend for an app running in the background. When I go to home-screen#1 and select MINE, WIFES, and CAVS.......that selection affects the widget on home-screen #7 as well. I go to screen #7, tell it to display Exchange only.......and when I go back to #1, it is switched to exchange.
So.....any way to do what I want?
1) Have a calendar on home-screen#1 that shows my Gmail calendar(s)
2) Have a calendar on home-screen#7 that shows my Exchange calendar
View 2 Replies
View Related
Sep 2, 2010
I got a Widget on my HomeScreen on which i add an click to a Button. I pass the widget id from the Widget to a Service, but when im reading the WidgetId at the Service it's always 3.
View 1 Replies
View Related
Jul 4, 2010
i'm using PreferenceActivity class to configure my widget. PreferenceActivity class automatically saves user preferences, so in widget update service i can call context.getSharedPreferences() and i obtain user preferences.Problem is follow: if you have many widget of same type, how PreferenceActivity class saves prefs? how i can load appWidgetId specific prefs from sharedPreferences?
View 7 Replies
View Related
Jan 12, 2010
I have an image put on an ImageButton, which looks good on a mdpi (medium-dpi) screen. However, when the device has a hdpi (high-dpi) screen, the image is still pixel-by-pixel accurate, which look small on the device screen.How do I make such that the image (and therefore the ImageButton) scaled based on the density-independent pixels (dp or dip) instead of pixels?
View 3 Replies
View Related
Mar 6, 2012
I 've been using my android from last 4 months and i just wanted to know how to make a rom based on stock rom or how can i get the stock rom which is just like custom rom in the sense of flashing/installing it...
View 1 Replies
View Related
Aug 19, 2010
I have a widget that displays a set of information. What I would like to do is to give the user the opportunity to choose the background color/image. I would like to have a popup when the user is selecting the widget to choose the background. So how would I make the popup? And how would I apply the background dynamically?
View 1 Replies
View Related
Mar 23, 2010
I have a singleton class and I am using it to access databases. I would like to know how it would behave if I use the same from my remote service class which runs as a separate process. Will it create a new instance in that process or will it use the instance from the other process?
View 3 Replies
View Related
Aug 22, 2010
I'm trying to get a simple vibration working and according to the api docs(http://developer.android.com/reference/android/os/Vibrator.html) all I need to use is this: public void vibrate (long milliseconds)
Turn the vibrator on. Parameters milliseconds How long to vibrate for.
However the behavior I am seeing is not what is described. Instead of a number of milliseconds, it seems this parameter translates into an "intensity"?
I tried: vibrator.vibrate(200);
And I got a sustained vibration which didn't stop until I exited my app. Initially I thought perhaps the api docs were wrong and the parameter was seconds, not milliseconds, so I tried: vibrator.vibrate(2);
This time I got the same behavior, i.e. continuous vibration, but the vibration was very gentle.. almost in-perceptible. This leads me to conclude that the parameter translates into an intensity, not a time.
Is it possible that this is a "feature" of the particular device? In my case HTC Desire.
I'm running 2.1 as my crappy telco hasn't distributed an update to 2.2, but it worries me that this behavior may differ from device to device.
View 4 Replies
View Related
Apr 7, 2010
I have a LinearLayout inside a HorizontalScrollView. The content is just a image. While scrolling, I need to achieve the same behavior you get when setting the paging option on a the iPhone equivalent of the HSW (scrolling the list should stop at every page on the list, not continue moving).
How is this done in Android? Should I implement this features by myself or there is a particular property to set or a subclass of HSV to implement?
View 1 Replies
View Related
Jul 30, 2010
Can anyone recommend a weather widget that displays the current weather based on location? Preferably cell tower info instead of gps and one that only used data every set interval based on my settings so that it doesn't use data constantly.
View 4 Replies
View Related
May 27, 2010
As far as I have read in the Internet and official documentation, it isn't possible to make a scrollable app widget. Also all my tries failed. I even tried to subclass TextView to implement my own scroll method, but nothing worked.Are there any ways to achieve that? there are solutions if you use for example htc sense or home desktop ++, but i want to make it available to other users which don't use this
View 3 Replies
View Related
Jun 20, 2010
how can i make a 4g widget for my hm screen? so i dont have to goto settings/wireless networks etc.
View 2 Replies
View Related
Dec 16, 2009
I know I could use it and I think others have mentioned they would like to use it in their apps. Currently it is "internal" so we're not supposed to use it and we have to "roll our own" which is a pain (I've done it). Also why does DatePicker only have a 200 year range (1900-2100)? Even the date gadget that the Pocket PC has goes back as far as mid 1700s. Add a range option on it.
View 2 Replies
View Related
Nov 11, 2010
Is there an app or widget that can be used to make a larger button? I'd prefer a 2x2 size that I can use to direct dial while driving rather than having to fiddle with the small 1x1 size, but anything bigger than the standard would be fine.
I've only found apps that make smaller buttons and one that makes me select subsequent options before I can actually call. I just want a large single press widget.
View 4 Replies
View Related
Jun 5, 2010
I want to make (yet another) news widget. Initially I thought it was enough to: 1. Download all the news articles 2. Update the widget every 5 seconds to change the currently displayed article using Alarm Manager (Alarm Manager.RTC) 3. Update the widget every 30-60 minutes to get new articles. This worked great on the first try but battery was quickly drained. I checked the logs and it turned out that the widget did the 5 second updates even if the screen was off. This was a surprise to me since the docs states: "..set an alarm with an Intent that your AppWidgetProvider receives, using the Alarm Manager. Set the alarm type to either ELAPSED_REAL TIME or RTC, which will only deliver the alarm when the device is awake. " I guess the device is considered "awake" even if screen is off? I found the same issue here: http://groups.google.com/group/android-developers/browse_thread/threa. I then checked the standard news widget and the other news widgets most popular on the Android Market and I see that they have services running all the time. Maybe because they want to handle the broadcast event when the screen is turned off? So is this really the best solution to have a service running in the background? So if someone downloads 10 different news widgets from different companies they end up with a list of 10 services in the "Running services" list?
View 6 Replies
View Related
May 23, 2010
I have developed a very simple widget that was meant to interact with the user via an ImageButton. What I am trying to do now is as follows. When a user taps the button (after adding the widget to their home screen), I want the phone to dial a certain telephone number.
View 2 Replies
View Related
Jul 31, 2010
It stinks that Samsung didnt make one but is it possible for a developer to make one that works with the Galaxy S default music player? I dont use a lock screen at all so I have no way of controlling the music besides going into the music player app. I am currently using Meridian player which has a music player widget btw. I plan to get the Epic 4g and want to use the samsung player, but it needs a widget
View 4 Replies
View Related
Nov 15, 2010
I have a widget, and I want it to make a phone call to a preset number when the user clicks on it. How do I do this? I havn't yet understood how widgets work, so it would be really helpful if you could provide a sample code.
View 4 Replies
View Related
Sep 14, 2010
is it possible to run multiple instances of the same app on android? What I mean if the app does not support multiple identities is it possible to install it twice and configure each instance separately?
View 1 Replies
View Related
Apr 14, 2009
My app has 4 activities on the stack A->B->C->D (top)
If you press home and re-enter the application, another instance of A is started, so the stack is A->B->C->D->A (top). I know this because when I press BACK, A is popped off and I now see D (instead of going to the Home screen).
What I want is that when the user re-enters the app, they re-enter on the same activity they were in before (D).
CODE:................
View 2 Replies
View Related
Mar 17, 2009
Is it possible to re-use all the instances of Activities and Services when an application is launched twice. For instance: 1/ I start my application APP1. Some activities are launched and a service is started. 2/ I click "Home" device button 3/ I can see the icon the launch again my application APP1 4/ I click on it and the APP1 is launched twice
I would like to re-use the existing the instances of Activities and Services from the first launch. I guess it is related to "SingleTop" or "SingleTask" but it doesn't seem to work.
View 11 Replies
View Related
Apr 15, 2010
I would like to do this, let me know if it possible in android?
App1 --> bindService() or startService() to AndroidService1 App2 --> bindService() or startService() to AndroidService1 (same service)
I would like App1 and App2 to get different instances of AndroidService1. Why I want to do this is say App2 doesn't need the service any more & it calls stopService() then App1 should still continue to work with its own instance of service app.
View 2 Replies
View Related
Jul 19, 2010
I have written some code in eclipse and I want to run it on two separate Android emulators.
How do I do this when I click "Run"?
I read online and it said I need to do AVD configuration. What is that and how do I do that?
View 2 Replies
View Related