Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make widget of running application in android?

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.

like image 531
anddev Avatar asked Jan 23 '12 09:01

anddev


3 Answers

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.

like image 94
Ilya Gazman Avatar answered Nov 16 '22 19:11

Ilya Gazman


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

like image 20
Shishir Shetty Avatar answered Nov 16 '22 20:11

Shishir Shetty


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.

like image 24
Gangnus Avatar answered Nov 16 '22 18:11

Gangnus