hello I have android application and I need to add badger to app launcher I searched on the internet and found this library
compile 'me.leolin:ShortcutBadger:1.1.4#aar'
is working but not for all device I tried at Samsung and HTC and its working but on Hawaii or sony not working how I can make this work for every Android device?
this is my code
int badgeCount = 0;
try {
badgeCount = Integer.parseInt(bundle.getString("badge"));
} catch (NumberFormatException e) {
e.printStackTrace();
}
try {
ShortcutBadger.applyCount(getApplicationContext(), badgeCount);
} catch (Exception e) {
e.printStackTrace();
Log.d("BADGE","BADGE");
}
then I tried to add permission to manifest like this, also not working
<!--for Samsung-->
<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
<!--for htc-->
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>
<!--for sony-->
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
<uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE"/>
<!--for apex-->
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
<!--for solid-->
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>
<!--for huawei-->
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/>
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS"/>
<!--for ZUK-->
<uses-permission android:name="android.permission.READ_APP_BADGE"/>
<!--for OPPO-->
<uses-permission android:name="com.oppo.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS"/>
<!--for EvMe-->
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_READ"/>
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_WRITE"/>
how i can make this work for every android device ?
You can't.
The decision of how to display things on the home screen is up to the developers of the home screen, not you. There are hundreds of different home screen implementations for Android, both pre-installed and user-installed. None have to offer any sort of API for app developers to set a badge on a launcher icon.
Some will have such an API and will document it. Some will have such an API for internal use, and developers of libraries like the one that you are trying to use may try to help you use those internal APIs. But many home screens will not have any sort of API for this.
Your primary choices are:
Stop trying to deal with launcher icon badges entirely.
Settle for what your library offers you.
Write your own home screen and attempt to force users to use your home screen, just so that you can have launcher icon badges.
Related
I developed an Android App with Qt. Some time ago I got an E-Mail "Approval for background location" from Play Store. I'm not familiar with Java and I don't understand the problem.
My App uses GPS only if the app is visible (in foreground), but not if it is invisible (background).
My Manifest.xml looks like this:
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="28"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.android.vending.BILLING"/>
Now I found on Play Store
...the ACCESS_BACKGROUND_LOCATION permission only affects an app's access to location when it runs in the background.
For me this means because I don't use ACCESS_BACKGROUND_LOCATION my App only uses GPS if it is visible (foreground). So what is the problem? Thanks...
I had a very similar problem. I double checked my AndroidManifest.xml, there was no ACCESS_BACKGROUND_LOCATION in it.
I use the QGeoPositionInfoSource from C++ to get periodic location updates. I never called the stopUpdates() function, that had to be fixed. It must be called when the app goes to background, e.g.: onPause.
Here is a very useful video with the clue, and some other useful reading material:
https://youtu.be/xTVeFJZQ28c?t=394
https://developer.android.com/training/location/permissions
https://youtu.be/xTVeFJZQ28c?t=394
https://developer.android.com/about/versions/oreo/background-location-limits
There is a signal QGuiApplication::applicationStateChanged which can be utilized for this, an example code:
if (const auto *const gui =
qobject_cast<const QGuiApplication *const>(qApp)) {
connect(gui, &QGuiApplication::applicationStateChanged, this,
[&](Qt::ApplicationState state) {
switch (state) {
case Qt::ApplicationState::ApplicationActive:
source->startUpdates();
break;
default:
source->stopUpdates();
}
});
}
The source is a pointer for the QGeoPositionInfoSource.
I need to show badge on App icon in my application
what i have tried:
This https://github.com/leolin310148/ShortcutBadger library do it on many devices.I have checked its manifest and saw that there exists a permission for each type of launcher
<!--for Samsung-->
<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
<!--for htc-->
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>
<!--for sony-->
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
<uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE"/>
<!--for apex-->
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
<!--for solid-->
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>
<!--for huawei-->
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" />
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS" />
<!--for ZUK-->
<uses-permission android:name="android.permission.READ_APP_BADGE"/>
2.I have gone through many available answers that are already on stackoverflow like
How to display count of notifications in app launcher icon
can we show badge number on android app icon like iphone?
How to show badge count with app icon on Redmi?
Add unread notification badge on android app icon
Is there a way to add a badge to an application icon in Android?
All these resources helped me to attain the task on above mentioned devices but i can still see there are lot man devices like xiomi,micromax etc in which app like wtsapp,facebook etc are showing badges but i am unable to show badge on these devices.
Have anyone here has achieved it.Any help will be appreciated.
This is not a feature the of Android system. Device manufacturers (like Xiaomi you mentioned) or launcher developers (like Nova Launcher) can implement it and expose an api for app developers, but there is no standard for that, nor is it expected by the users to be there.
In general, you should not try to do this on Android.
For displaying badge, Google may have stopped showing numbers count on App Icon as a badge but I think it's still showing a dot to let the user know there is something new to that app.
For more information you can go through this official link from Google : https://developer.android.com/training/notify-user/badges
You can! From the doc: https://developer.android.com/training/notify-user/badges
By default, each notification increments a number displayed, but you can override this number for your app. For example, this might be useful if you're using just one notification to represent multiple new messages but you want the count here to represent the number of total new messages.
To set a custom number, call setNumber() on the notification, as shown here:
var notification = NotificationCompat.Builder(this#MainActivity, CHANNEL_ID)
.setContentTitle("New Messages")
.setContentText("You've received 3 new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
.setNumber(messageCount)
.build()
I'm developing an alarm aplication, so when the alarm goes on it start an activity with an off button
It's very simple, but my question, is there a way to start the activity even if the device is locked???
You need to use the WakeLock and also disable your keyboard for the respective Activity. They can be achieved by help of WindowManager.LayoutParams class.
WakeLock allows your app to wake up the screen i.e. turn the display on while your Activity or your complete app is running in the foreground. To learn more about implementing the WakeLock go through the following link:
http://developer.android.com/training/scheduling/wakelock.html
To disable your keyguard you need to use WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED and/or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD flags for the respective Activity.
To know more about them, go to the following links:
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_DISMISS_KEYGUARD
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SHOW_WHEN_LOCKED
You will also need to use the following permissions in the Manifest file of your Android Project:
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
You need the following permission in AndroidManifest.xml file:
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
Check this link
In Eclipse we were able to add permissions in AndroidManifest.xml by going to AndroidManifest.xml->Permission-> Adding permissions.
How to add permissions in Android Studio? How can we get a list of all the permissions that we can add to an Activity ?
You can only type them manually, but the content assist helps you there, so it is pretty easy.
Add this line
<uses-permission android:name="android.permission."/>
and hit ctrl + space after the dot (or cmd + space on Mac). If you need an explanation for the permission, you can hit ctrl + q.
You can type them manually but the editor will assist you.
http://developer.android.com/reference/android/Manifest.permission.html
You can see the snap sot below.
As soon as you type "a" inside the quotes you get a list of permissions and also hint to move caret up and down to select the same.
Go to Android Manifest.xml
and be sure to add the <uses-permission tag > inside the manifest tag but Outside of all other tags..
<manifest xlmns:android...>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
This is an example of the permission of using Internet.
You can add manually in the manifest file within manifest tag by:
<uses-permission android:name="android.permission.CAMERA"/>
This permission is required to be able to access the camera device.
It's quite simple.
All you need to do is:
Right click above application tag and click on Generate
Click on XML tag
Click on user-permission
Enter the name of your permission.
Put these two line in your AndroidMainfest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I am developing an app and in the manifest I have:
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
When I click on the button to execute this code:
Intent intentcall = new Intent();
intentcall.setAction(Intent.ACTION_CALL);
intentcall.setData(Uri.parse("tel:" + phonenumber)); // set the Uri
startActivity(intentcall);
It will run fine on phones, and on tablets it pops up with a display where you can view or add the number to contacts. However, if I keep the permission in the manifest, it isn't available for tablets in the market. How can I keep the code behavior and still have it display in the market for tablets as well as phones?
In the AndroidManifest you need:
<uses-feature android:name="android.hardware.telephony" android:required="false" />
The CALL_PHONE permission implies telephony is required, but if you specify that is not you won't be filtered.
Try to use Intent.ACTION_DIAL instead Intent.ACTION_CALL.
For example:
try {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone_number));
startActivity(intent);
} catch (Exception e) {
//TODO smth
}
And in this case you can completely remove these tags from AndroidManifest.xml:
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-feature android:name="android.hardware.telephony" android:required="false" />
Regarding "uses-feature" and it crashing - are you checking that telephony is available before actually making the call? It might be you need to do that extra step for the case when the app is on tablets. All you are saying in the manifest is that the feature is not required. It probably relies on you to actually implement the logic around that.
Instead of adding a user with the ACTION_CALL identifier, change it to ACTION_INSERT_OR_EDIT.
You'll need these permissions too, instead of the CALL_PHONE permission:
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>
Take a look at this related question:
can't find app on market
From google docs:
Declared elements are informational only, meaning that
the Android system itself does not check for matching feature support
on the device before installing an application
usage is only for google play