I must make something like that.
I run my application and press button "Create widget" and the widget is created on Home screen.
I don't know how to do it, Just i know how to take widget to home screen when i choose my widget in widgets menu and write text what i want in this widget
And I know how to run ConfigureActivity on my application but when i writte some text and press add "widget" it don't create. I think i don't have any id's to create widget but how to get that? Random or something.
I used in Android Studio New > Widget > App Widget.
I run my application and press button "Create widget" and the widget is created on Home screen.
This is not possible. The only app that can add an app widget to the home screen is the home screen itself.
Related
I have developed a Widget for my Android App, and It can be added in following ways.
User can long press in the Home launcher and select Widgets and then drag and drop to Home Launcher Screen, like this -
and then
From the App, in a button click, If
Build.VERSION_CODES.O && appWidgetManager.isRequestPinAppWidgetSupported is true
then we call
appWidgetManager.requestPinAppWidget
And It works, for some devices It doesn't work even if isRequestPinAppWidgetSupported was true.
I am looking for a way to navigate user to 1st way ( going to select widget screen) from my app, whenever isRequestPinAppWidgetSupported was false.
I've used:
addWidgetActivityLauncher.launch(Intent(AppWidgetManager.ACTION_APPWIDGET_PICK).apply { putExtra(EXTRA_APPWIDGET_ID,requireActivity().appW.allocateAppWidgetId()) })
But this opens up a screen like this
,
but clicking on my widget doesn't do anything. Just closes this dialog.
I want to automate the 1st way till the widget selection screen from my app.
PLease help me discover what I am missing.
I want to implement button as a widget. The button has a primary function in app. On clicking the button in app it redirect to another fragment and play a sound.
Is there any way to do so from widget i.e, making the button work same function ?
From what i understand, you mean the launcher widget that sits on the app tray/menu? If so, just create an activity with that functionality and set it as the launcher activity. Thats the activity that will launch when the widget is tapped.
How to create widgets on our own home application. So that user can get all the user installed widget on press of a button and delete it on press of back button
I have made a digital clock as a widget using appWidgetManager in android. Now i want to move that clock on the homescreen. Please Help
Thanks!
Do following steps:
Long press on home screen
Select "widget" from list
Select the widget you want to add from the list
The selected widget will be added to your home screen.
I have found examples here: Android - Intent that open widget context menu and here: http://coderender.blogspot.com/.
The first one launches the widget picker, but goes it goes away when you select anything. The second one lets you pick a widget, but it shows it in the application view. Is there a way to call the widget selection from a button in an app but still have the main screen on the phone be the AppWidgetHost?
It may be me misinterpreting things, but it looks to me like the AppWidgetHost has to be the application where you are calling the widget selection menu.
Is there a way to call the widget selection from a button in an app but still have the main screen on the phone be the AppWidgetHost?
Only if you are the home screen.
It may be me misinterpreting things, but it looks to me like the AppWidgetHost has to be the application where you are calling the widget selection menu.
More importantly, it is the AppWidgetHost that must do the work to make use of the selection.