Launch Android Widget from Activity - android

Is there any way we can launch the android widget from our application immediately application installation or by showing button(eg:- 'Add Widget') within the application. So it like automatically add widget to our home screen using code.
Thanks
Prakhs

I'm not sure I understand the question fully, but I'll give it a try:
There is no way to start an application automatically after it was installed.
There is the ACTION_PACKAGE_ADDED Broadcast Intent, but the application being installed doesn't receive this.
Android applications can not add App Widgets to the home screen. Applications can define App Widgets, but user has to add them manually to the home screen.

Related

Integrate an apk into AOSP's build system and run it on boot

I would like to have an app (LMT from XDA specifically) Bundled in AOSP/LineageOS.
I can do it via adding it in a Android.mk file , so that's not an issue.
My issue is that I want to have this app launch every time I reboot and unlock my phone.
The reason being I disable the navigation bar and use LMT to navigate, but I cannot use it every time I start my phone as LMT does not auto start.
I am on Android 10.
Can anyone help me figure out a way to tell the system to start LMT every boot?
The app that starts first and shows your Home screen, App drawer etc. is called a Launcher.
You can either:
Have your new app be a Launcher app. You'll need to modify it to add the HOME intent, and also set it as the default launcher of the system.
Or modify your current Launcher app to open your app as soon as it itself starts.

Android Studio How to run application but it should not have launcher

I have an application which I simply want to run but it should not have launcher Icon.
I have deleted this tag
category android:name="android.intent.category.LAUNCHER" />
But then Android studio starts to give error that
Could not identify launch activity: Default Activity not found
Error while Launching activity
then I switched the run configuration as the following :
What I want :
I just want that My application start running once I run it from the android studio , but it must not have launcher icon . SO that user should not be able to launch it by himself.
Note:
I do know that it is not legal we should have activity so that user can se it , use it and change something if he wants. But that is not the case in my app as the user want himself to hide its launcher so that no body knows about app. So do not worry about such case. :)
I have an application which I simply want to run but it should not have launcher Icon.
Then your app will never run.
running service or broadcast receiver
Your app, once installed, is in a stopped state. None of your code will run until something uses an explicit Intent to start one of your components. Normally, that is the launcher icon. Other possibilities include if the user sets up an app widget, or if your app is a plugin for some other app (and that other app uses an explicit Intent to start one of your components). Outside of those scenarios, your app will never run. This is to help prevent malware.
the user want himself to hide its launcher so that no body knows about app
You will still need a launcher icon. However, when the user runs your app, you can use PackageManager and setComponentEnabledSetting() to disable that activity, so it will no longer show up in the launcher.

Setting app icon on home(main) screen default

i'm working on an sms management application, it works instead of native android sms manager but i want to show my app on home(main) -i mean 1st screen-programatically.My application now seems on 6th screen and diffullt to reach to write a message.How can i put my app on home(main) screen?
I think you just need to move the app starter to the desired place. Moving an app starter can be done with long click on the app starter icon and then move it to the right place.
If a new android application is installed it automatically places it to the end of the app list on your phone. You have to move it then manually...
I agree with Lorenz, you cannot force your application to specific place in application list.
But you can add a shortcut to Home Screen whenever you launch the application, so that application is always accessible from HOME.
Try this for adding shortcut.

Place app widget on homescreen out of an activity

I know that it's not possible to place an app widget programatically on the homescreen - the user has to do it by himself. But is there a way, to let the user create an app widget without having to go to the "widgets-tab" and choosing it from the list of all available widgets?
My idea is to have a Button in my Activity, which provides some kind of shortcut to that list . This way the user still would create it by himself, but he wouldn't have to leave the app. Is there an Intent I could use in combination with startActivityForResult()?
Have a look at CommonsWare answer here:
Add widget to homescreen from Android application
You can bring the list up put you are unable to select a widget and install it for that your app must be an appWidgetHost
In Android O, its possible to pin app widget programmatically. Just watch at example here
Also check out Google official documentation

Accessing AppWidgetHost to launch the 'Add Widget' activity from within my program's activity

I would like to add the ability for a user to launch the Add Widget activity to choose my application's widget to add to their phone's homescreen from within my application.
I was following this example: Android:NPE while trying to activityForResult with ACTION_APPWIDGET_PICK intent, but realized that I didn't have the homescreens AppWidgetHost.
I know I need to use the AppWidgetManager.ACTION_APPWIDGET_PICK, but Android Developer says that I need to launch this from within my AppWidgetHost. If I am trying to get the appwidget onto the homescreen, this implies that I need to gain access to that instance of the AppWidgetHost. How would I get access to that or get that instance? Is it even possible to do anything with the homescreen's AppWidgetHost?
How would I get access to that or get that instance?
You can't. That's not in your process.
Is it even possible to do anything with the homescreen's AppWidgetHost?
Only if you are the home screen in question.
I would like to add the ability for a user to launch the Add Widget activity to choose my application's widget to add to their phone's homescreen from within my application.
AFAIK, this is not supported.

Categories

Resources