Google's geofence app not working - android

I have downloaded a Geofence Sample Application form here but it is not working .I have replaced actions in GeofenceUtils class by putting app package name e.g com.example.android.geofence.ACTION_CONNECTION_ERROR is replaced by com.geofencesample.ACTION_CONNECTION_ERROR , here com.geofencesample is my app package name .I have put all the possible permissions regarding Location in manifest file , here is my manifest file .
MANIFEST FILE :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.geofencesample"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<!--
Requests address-level location access, which is usually
necessary for geofencing
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/title_activity_geofence"
android:theme="#style/AppTheme" >
<activity
android:name="com.geofencesample.MainActivity"
android:label="#string/title_activity_geofence" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!--
This activity should be linked to the app's Launcher icon
-->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="com.geofencesample.ReceiveTransitionsIntentService"
android:exported="true" >
</service>
</application>
</manifest>
I am passing lattitude , logitude and radius(10m) of geofence through UI , After clicking on "Register geofence" button I am entering and exiting from geofence but nothing happens . I am not getting any notification or any vibrate alert (I have added it in MainActivity$GeofenceSampleReceiver.handleGeofenceTransition) . Which suitable fix should I do .
Any help will be appreciated .

I have tested it using proper radius and app package name .Now App is working ,but in some cases it gives false entry notification . I am using Mock Locations provider app so that I can test it by keeping himself at a place . Still I am not getting proper notification .

Related

camera and storage permissions isn't working in the webiew

I'm loading my website in webview. And inside that website also contains two buttons "Take photo" and "Upload". In the browser on the phone it works perfectly. As in, the "Take photo" button lets you take a photo, and the "Upload" button lets you upload a photo. But inside my app, it doesn't seem to do anything. And I know this has something to do with permissions. Here's my code:
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_favicon_1144_rounded"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/Theme.Test2">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I haven't changed my MainActivity.kt at all, but if you want, I can edit this question and add it in.
This is not possible. From android app webview, you can not get access to device's permissions.

Android: get current device location without asking permission at run time

I've created a hospital related app where i want to know the whether patient has visited the doctor or not, getting the location is the requirement of my app.
I've used ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permission in manifest. The problem is whenever application tries to get the location at run time the system prompts a security dialog which says "this app is trying to obtain your current location" and asks user to allow or deny it,, and if user clicks on the deny button the location is not fetched..
I don't want the user to click on the deny button is there any way i can skip this security dialog and set 'always allow' option in my app permission through code and get the location without ever prompting the user for access.
manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kaizen"
android:versionCode="4"
android:versionName="1.1" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:name="com.kaizen.volley.VolleySingleton"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.kaizen.SplashScreen"
android:configChanges="keyboardHidden"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.kaizen.Login"
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity
android:name="com.kaizen.AppMenu"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity
android:name="com.kaizen.SignUp"
android:windowSoftInputMode="stateHidden|adjustResize" />
</application>
The dialog you're seeing surely is a vendor specific feature. E.g. there is some function called KNOX for Samsung business devices, that seems to behave like what you're seeing. Once you found out where it comes from exactly, I wouldn't care about it any further. This is not widely spread and in those cases where the message pops up it will do for a reason: the user wants (or is forced by his administrator) to be informed about certain actions, such as apps wanting to get the current location.
You may check the normal behavior of your app in an emulator, if you do not have another device.

Android Map view does'nt work (white screen)

I devleop an app which one of its abilities is to view a map and display nearby places (does not matter really what it displays).
for my convenience - i coded it in separate project.
after i copied the code (with all of the resources) to the main app, and tried to display the map, I could not see the map at all. instead, i saw default white screen.
I generated the suitable keys (API and server) for every project, and enabled the needed API's (seperately):
BigQuery API.
Debuglet Controller API.
Google Cloud Logging API.
Google Cloud SQL.
Google Cloud Storage.
Google Cloud Storage JSON API.
Google Maps Android API v2.
Google Maps Geolocation API.
Google Places API for Android.
Google Places API Web Service.
and this is my androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk android:minSdkVersion="16"
android:maxSdkVersion="22"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.NETWORK" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#mipmap/icon_mykehila"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
....
....
....
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name=".Maps.MapsActivity"
android:label="#string/title_activity_maps" >
</activity>
...
....
</application>
The weirdest thing is that it works perfectly on the small app, but not on the main app when I try to run it from there.
What can it be?
The only way to solve it was to Edit allowed android applications in the console to "Any application allowed".
I don't know why but this was the only way.

How to specify hardware requirement through code?

I have an android application which has a provision to controls calls ie, allow or block specific incoming & outgoing phone calls.Here is part of manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xxxx.xxxxxx.xxxxxxx"
android:installLocation="internalOnly"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application>
</activities>
</services>
<receiver android:name="xxxx.xxxx.ReceiverOutGoingCall" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
<receiver android:name="xxxx.xxxx.ReceiverIncomingCall" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
</manifest>
This application does not show for some devices in Google play.After a long time search I understood that it is due to <uses-feature> hardware requirements. No i want to remove the required hardware features for phone calls from manifest and check them from code.
Some tablets which does not have a Phone Call functionality does not show my application.So i want to make my application available to these tablets which lacks the required hardware.How can i achieve this?
Thanks in Advance
Some permissions automatically impy feature requirements.
This is what the API Guides says:
"For any of the permissions below, you can disable filtering based on the implied feature by explicitly declaring the implied feature explicitly, in a element, with an android:required="false" attribute."
Your permissions impliy the features android.hardware.wifi, android.hardware.location.network, android.hardware.location.gps, android.hardware.location and android.hardware.telephony.
You set only two of them to android:required="false". So you might try to set the other permissions to not required, too.
Unfortunately, there isn't a way to add permissions after the application is installed. Perhaps you can release 2 APKs. One for mobile devices and one for tablets.
Try this code to check if phone functionality is available :
public static boolean isTablet(Context context) {
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
return manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE;
}

Register device on GCM: onRegistered isn't called

I'm using GCM on my application, but when I try to register my device the onRegistered method on GCMIntentService isn't called.
I installed the GCM demo application on my device and it works:
http://developer.android.com/guide/google/gcm/demo.html
In this app the device is registered and I can send messages to it. I tried to use GCM in my own app using the same GCMIntentService. I adapted the manifest too, but when I try to register this is what appears in my log:
09-25 10:00:10.195: V/GCMRegistrar(591): Registering app com.pfc.dps of senders 38322290XXXXX
And nothing else, I get no response. These are my manifest permissions:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pfc.dps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.USE_CREDENTIALS"></uses-permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Creates a custom permission so only this app can receive its messages. -->
<permission
android:name="com.pfc.dps.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission
android:name="com.pfc.dps.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission
android:name="com.google.android.c2dm.permission.RECEIVE" />
I created a new project in Google APIs console to check if it worked that way, but I get the same result using any of the Sender IDs.
Does anybody know why is that?
Thank you!
After the "Registering app *your_package* of senders *sender_id*"
You should receive a onReceive event which will call your GCMIntentService to wake your app up.
If you do not have that, please check you have missed the receiver or forgotten to change the category for your own package.
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="***your_package***" />
</intent-filter>
</receiver>

Categories

Resources