Android Widgets separate apps? - android-widget

I hate to sound like terrible newb, but are Widgets separate apps? For instance, I am creating a news reader app for Android and I want a homescreen widget. Do I create the widget as a separate project/app that hooks into the other app, or do I add the code for the widget to the original news reader app so that they are installed in tandem?
If it is a separate project/app, then how do I make sure it is installed when the "parent app" is installed, or is that sort of thing totally off base?
Thanks for any help you can offer!
P.S. Also, I have mostly been an iOS user and I'm just now getting into Android and I don't have a phone, just a tablet. So I haven't absorbed common forms and examples yet.

Just wanted to answer my own question in case anyone else comes along looking for answers. The home screen widget for an app is indeed not a separate app. All it takes to initialize a widget is to declare a BroadcastReceiver in the AndroidManifest.xml file.
Mine looks like this:
<receiver android:name=".receivers.PWReceiver" android:label="#string/widget_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="#xml/widget_config" />
</receiver>

Related

Avoid deep link calls onGenerateRoute in Flutter app?

I'm trying to handle deeplinking in my Flutter app with uni_links package.
Is there a way to avoid onGenerateRoute is called by the launch deep linking? I have my own routing logic and I just need to get the deeplink string (I already do) and nothing else, I don't need to be routed anywhere.
For android,
in AndroidManifest.xml inside <activity> tag, please add
<meta-data android:name="flutter_deeplinking_enabled" android:value="false" />
More info: https://docs.flutter.dev/development/ui/navigation/deep-linking#enable-deep-linking-on-android
For iOS
Inside Info.plist, add
<key>FlutterDeepLinkingEnabled</key> <true/>
More info: https://docs.flutter.dev/development/ui/navigation/deep-linking#enable-deep-linking-on-ios

Flutter FIrebase Admob crashing on app start even though i have added all required setups

I am trying to implement Google Admob in Flutter. I have added the required dependencies:
Android Manifest;
Added Initialization in the app
I have a google-services.json file added to my project which is the same one I have been using for Firestore etc. successfully.
But the app just does not seem to want to start. If I remove the Admob dependency from my pubspec file, the app works so this is definitely to so with the Admob.
I know that the testAppId pulls through the same appid specified in AndroidManifest as this is the google test ad id.
I have not yet implemented any banners, interstitials as yet. i am just trying to initialize first and at least get the app running.
What am I doing wrong?
So it seems the firebase_admob documentation needs to be updated as it is inaccurate.
The issue is related to the placement of the meta-data tag inside the Android Manifest.
The document indicates to place it within <application>, however it does not indicate what to do if you also have a tag for <activity> :
<manifest>
<application>
<!-- TODO: Replace with your real AdMob app ID -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-################~##########"/>
</application>
</manifest>
However, this does not work. I stumbled across the following video(https://www.youtube.com/watch?v=d2aCCIIUebc --> check the 17:20 mark) by chance and the user indicated the same problem and it is solved by moving the tag as following:
<manifest>
<application>
<activity
</activity>
<meta-data
<!-- TODO: Replace with your real AdMob app ID -->
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-################~##########"/>
</application>
</manifest>
Note: the change is to move the Meta-data tag to outside the application tag. This solves the problem and the app does not crash and loads ads as expected.

How to get permission with a description?

I found on an application that asks permission to use bluetooth with a description of why this is needed. I need to implement this in my application.
How to name this function? How can this be done on ionic?
This BT request would have to be triggered via a cordova plugin, eg this one for iOS:
https://github.com/swetha-thoomoju/cordova-plugin-ios-bluetooth-permissions
..or by editing cordova's config.xml to include:
<config-file parent="NSBluetoothAlwaysUsageDescription" target="*-Info.plist">
<string>Improve location accuracy when finding nearby services</string>
</config-file>
The above is only for iOS, but I'm pretty sure something exists for Android as well.

Flutter drag and drop inside UI in desktop application

Talking about a desktop application now, not mobile or web.
Is it any widget in Flutter that will allow, for example, drag a folder, drop it in the application UI, and the app will read for example the path to that file or folder?
I have been reading about Draggable and DragTarget in Flutter, but i do think they are used for that purpose.
NOTE: it might not exist a widget for that purpose, so a strategy on how to do that in Flutter will also be appreciated.
Assuming you're talking about dragging from outside the application, it's not currently supported; Flutter #30719 would be the issue to watch/upvote.
Depending on the specific platform you might be able to implement it with a plugin in the short term (if you are familiar with native development on that platform), but that would likely be more work than contributing an implementation to Flutter itself.
Flutter has a dependency to support such behavior now. Check this link
https://pub.dev/packages/desktop_drop

Can multiple versions of the same iphone or android app use shared code or libraries?

Let's say I write an app that displays restaurant menus and lets a user order items from them. I'll call it RestaurantMenuApp. I'd like to have this main application be branded under my company name. It would allow users to view multiple different restaurants and place orders on any of them. Purchases are done through API calls to my web service using my company's merchant account.
Now let's say I also want to sell customized versions of this app to individual restaurants. The customized version would be themed just for that restaurant, only show their menus, locations, their promos, and so forth. It would make the restaurant look like they built their own custom app. Purchases are still done through API calls to my web service, but each branded version can use their own merchant account.
I'm wondering if each application (the main RestaurantMenuApp and each individually customized restaurant app) has to contain an entire copy of the entire application. Is it possible to have each app install a shared library that all of the apps use? If any of the apps has already installed this shared library, the others apps don't need to install it as well?
I'm new to mobile app development and searched for answers, but could only find solutions for how to build lite vs. full versions of the same app. It was not clear if these apps could SHARE code to make each install smaller.
For iPhone/iOS App store apps, an OS enforced security sandbox prohibits apps from sharing any code.
For iPhone, the inter-app communication is restricted almost to none. Apple designed the iOS this way for the benefit, arguably, of security and user experience.
On Android, there is much more flexibility in inter-app communication. There are several ways to achieve what you want.
First, you can use service. Service processes on Android are pretty much like service processes on Windows. They are running in the background all the time. There is an code sample.
http://marakana.com/forums/android/examples/60.html
Or you can use intents. Intent receivers register with the Android OS to specify what action and data format that they will handle. For example, an intent filter like below tells the Android OS that the receive will be able to view, edit, and pick any mime type of vnd.android.cursor.dir/vnd.google.note. So you can create a component as intent receivers to take care of a special data format. In another Android app, you then push out your data and the intent receiver will take over from there.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
</intent-filter>
For more information on intent filter, you can refer to this doc.
http://developer.android.com/guide/topics/intents/intents-filters.html