Turning on the internet data packets in android - android

what i am doing::
I have disabled the datapackets so i don't have a internet connection
at the moment in emulator
Now i am checking whether the internet connection is available if not
availabe i am using this code below to launch the screen so that i
can enable the datapackets
code::startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
This code takes me to page::
When i click on button it shows turning wifion.... but it is not switching on no matter how long i wait
But when i close the app and go to settings manually. I can turn it on
The permissions i have used are below::
<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.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
What is that i am doing wrong here ? how can i correct myself !

try this code.it might helps you
Intent gpsOptionsIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
startActivityForResult(gpsOptionsIntent,0);
if you are using wifiManager than you will need this permission.
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

Related

GPS State with Chinese phone (VeryKool S352)

In my app, I'm checking the geolocalization state with this test
--> I need the user to have Wifi and GPS Enabled-
public boolean enableGPSifDown() {
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
return true;
The thing is in the cel (Android 4.2.2), all the GPS checkbox are cheked and wifi is on, nevertheless, this method always return false.
I've been using this method for all kind of cells ( Samsung, motorola, alcatel, sony, etc...) and never had problem with that, but with this "verykool" phone, it gives me false???
I have the permission :
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Any idea other than change the phone????

Turn speaker to ON on call connect

I'm trying to dial a number and when the call connects turn ON the speaker.
I've already read lots of topics that achieve this problem, but cannot get it working.
This is what I have.
Toast.makeText(getApplicationContext(), "CALL_STATE_OFFHOOK",
Toast.LENGTH_LONG).show();
Context context = (Context)getApplicationContext();
AudioManager audioManager2 = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
audioManager2.setMode(AudioManager.MODE_IN_CALL);
audioManager2.setSpeakerphoneOn(true);
The listener is working fine. I can see the toast "CALL_STATE_OFFHOOK" when the call is established, but the rest of the code is not working.
Am I missing something ?
Thanks !
UPDATE
This are my permissions
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
UPDATE 2
Actually calling:
audioManager2.isSpeakerphoneOn()
returns false before
audioManager2.setSpeakerphoneOn(true);
and
audioManager2.isSpeakerphoneOn()
returns true after
audioManager2.setSpeakerphoneOn(true);
but the speaker really did not turn ON.
Did you set the option "AUDIO_SETTINGS" on true in your manifest?

Phone call function intent not working in android

I have made a simple app,In that i want to make a phone call on click of a text view,But I am getting an exception that "No activity found that can do this action"..I have tried a lot and gives all permission to manifest,But still having the same error".
main.java
Intent dialer = new Intent(Intent.ACTION_CALL,
Uri.parse("9033309332"));
startActivity(dialer);
manifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
Try to use this code.
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:9033309332"));
startActivity(callIntent);
I also had the same problem. Most probably it may be because our device grant the permission to that app then it may work. Just go to settings and grant the permission.

Get neighboring cell in Android returns null

I'm trying to get the neighbouring cell info in Android but the function getNeighboringCellInfo() always return null.
I used the following code :
protected void getCellInfo() {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
List<NeighboringCellInfo> neighborCells = telephonyManager.getNeighboringCellInfo();
if (neighborCells == null) {
OutUtils.debug("no neighbor cells");
} else {
...
}
}
The context variable is from a Service class.
My AndroidManifest.xml permission
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I tried with and without enabling the "Use 2G networks" option in Android.
Any idea ? Thanks
If you can run logcat, try running logcat -b radio. If you are lucky, the RIL code will be spitting out debug messages, showing the actual request to the modem for the neighboring cell info. It could well be that the modem is just returning an empty list. If this is the case, it has nothing to do with permissions, and there is not much you can to fix it.
The cellid implementation varies from mobile device to mobile device since these features are considered to be optional. for example:
Samsung (all devices): getNeigbouringCells () is not supported at all and always returns an empty list.
according to this: http://wiki.opencellid.org/wiki/Android_library
and this: https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=24306
I think, maybe you haven't set all necessary permissions in Manifest. look here Null Issue with NeighboringCellInfo, CID and LAC
If you think you have them, put the manifest in the question, too, please.

Android - Simple permissions - Why don't I need this permission?

I'm currently working images using
mBitmap = BitmapFactory.decodeFile(filePath);
ExifInterface exif = new ExifInterface(filePath);
My permissions are:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
I thought I needed a read storage permission to get the files from the gallery. Why can I access files from my Gallery without this permission?
If it helps, I'm using the ACTION_SEND intent filter to start the activity via a "Share" dialog.
Edit: Just to clarify, my application works perfectly. I thought I would need a special permission to read files from the SD card (such as images). Is this not the case?
this is
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Categories

Resources