9

I want to make my running application's widget. I mean I want to access my application through widget on home screen. I want to dial a call, send sms to particular number which is stored in my application.

Is it possible in android? I am stuck on this if anyone has any type of idea then please suggest me..

Edit:-

I want to make widget like Power Control. In this we can operate all features of settings through widget. At the same ways I want to control my application through widget and for that I have to sync my application with widget or visa-versa. So I am not able to understand how can I do that.. Can anyone help me in this manner?

Thanks.

8
  • I am not able to understand what you want to say.. :(
    – anddev
    Jan 23, 2012 at 9:17
  • 2
    whenever any user answers you and if that answer suits properly to you then tick the "tick" mark below the down vote symbol in left side of the answer. This way that answer may be useful for others as well
    – Lucifer
    Jan 23, 2012 at 9:18
  • Yes but how can I do that in my own question?
    – anddev
    Jan 23, 2012 at 9:32
  • not in question, you need to do it in answer,
    – Lucifer
    Jan 23, 2012 at 9:33
  • 1
    Yes but the answer is must be correct and useful. Is it..??
    – anddev
    Jan 23, 2012 at 9:34

4 Answers 4

3

You can create broadcast receiver to consume all the broadcast events, and it doesn't matter if you fire broadcast events from your application of from your widget, they all will be handled at your broadcast listener.

0
1

There is no shortcut to convert an app to widget. Sorry buddy.

1

You should do an additional component to your application. That component will be widget. In Eclipse you could add a new class to your package through the wizard and say that it will be a widget.

It should have simple layout - check elements you used in the view. only FrameLayout, LinearLayout, RelativeLayout, AnalogClock, Button, Chronometer, ImageButton, ImageView, ProgressBar, TextView, ViewFlipper are allowed. Using forbidden elements causes "Problem Loading Widget" message. Beware!

I think, you have already seen that page about how to place a widget in Manifest and how to make an appwidget-provider.

After installing on the device or emulator you whould install widget to the screen. Long touch will conduct you to the widget install wizard of the device/emulator. You will need to do it only once - at every debug launch you'll have the new version on the right place automatically.

Don't forget to renew all important views though - it will not be done automatically. (check what is not refreshing by itself and refresh them in code).

I think, you already know, how to call your launch Activity from the widget body. Only now it won't be launch activity already, but the activity to be first launched from the widget. The widget will be declared as launch in the Manifest.

0

System settings: just localize your settings-modifying logic in one class (like PowerControlHelper or something), figure out what parameters your methods will take and reuse it both in widget and in full-UI application. Not much difference there, you can access all the same android APIs from within widget logic as well as from activity logic.

Your application's own settings: it doesn't matter where you access your private data as long as it's the same application. See http://developer.android.com/guide/topics/data/data-storage.html#pref for more details on Shared Preferences.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.