मैं एंड्रॉइड विकास के लिए बिल्कुल नया हूं, लेकिन मैंने पहले जावा (और अन्य प्रोग्रामिंग भाषाओं) के साथ काम किया है।AndroidManifest अनुमतियां मेरे एप्लिकेशन में क्यों सेट नहीं की जा रही हैं
मैं अपने एप्लिकेशन को विकसित करने के लिए एंड्रॉइड स्टूडियो का उपयोग कर रहा हूं और स्थान जानकारी (http://developer.android.com/training/location/index.html) तक पहुंचने पर डेवलपर ट्यूटोरियल का पालन करते समय मैं अटक गया हूं। मैं समझता हूँ कि स्थान सेवाएं android.permission.ACCESS_COARSE_LOCATION
और/या android.permission.ACCESS_FINE_LOCATION
अनुमति की आवश्यकता है, लेकिन उन्हें अपने ApplicationManifest अपने आवेदन को जोड़ने पर अभी भी एक SecurityException
java.lang.SecurityException: Client must have ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to perform any location operations.
मैं परेशानी हो रही लोगों के कई अन्य मामलों का सामना करना पड़ा साथ दुर्घटनाओं, लेकिन इन आमतौर पर गलत-प्लेसिंग(), गलत वर्तनी (ACCESS_FINE_LOCATION AndroidManifest Permissions Not Being Granted) या अनुमति स्ट्रिंग का गलत पूंजीकरण का परिणाम रहा है।
यहाँ मेरी ApplicationManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="scd.tt" >
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher_tt_v2"
android:label="@string/app_name"
android:theme="@style/TT_Theme">
<activity
android:name=".MainActivity"
android:theme="@style/TT_Theme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity" android:theme="@style/TT_Theme.NoActionBar" />
<activity android:name=".IndexActivity" />
</application>
</manifest>
मैं भी ACCESS_NETWORK_STATE और इंटरनेट दूर करने के लिए अगर यह अन्य SecurityExceptions का कारण होता है के रूप में आवेदन एक HTTP सर्वर के साथ संवाद करने की आवश्यकता है (जो यह करता है देखने के लिए कोशिश की है है सफलतापूर्वक) स्थान जानकारी प्राप्त करने के प्रयासों से पहले।
ऐसा लगता है कि जब मैं प्रोग्राम चलाता हूं तो AndroidManifest पर अनुमतियों में किए गए संशोधन को अद्यतन नहीं किया जा रहा है। मैंने बिल्ड मेनू का उपयोग करके एप्लिकेशन को साफ और पुनर्निर्माण करने का भी प्रयास किया है।
अद्यतन:
यहाँ गतिविधि की मूल है; मैं
package scd.tt;
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import java.util.Map;
/**
* Created by Liam on 08/09/2015
*/
public class IndexActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {
private GoogleApiClient mGoogleApiClient;
private LocationRequest mLocationRequest;
private Location mLastLocation;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_index);
if(debug) Log.d(TAG, "onCreate() called: savedInstanceState is " + (savedInstanceState == null ? "null" : "not null"));
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(10000);
mLocationRequest.setFastestInterval(1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
buildGoogleApiClient();
if (findViewById(R.id.index_fragment_container) != null) {
if (savedInstanceState != null) return;
Fragment index = new IndexFragment();
index.setArguments(getIntent().getExtras());
getFragmentManager().beginTransaction().add(R.id.index_fragment_container, index).commit();
}
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
protected void onStop() {
super.onStop();
mGoogleApiClient.disconnect();
}
@Override
public void onConnected(Bundle bundle) {
if(debug) Log.d(TAG, "onConnected");
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
startLocationUpdates();
}
@Override
public void onConnectionSuspended(int i) {
if(debug) Log.d(TAG, "Connection Suspended");
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
if(debug) Log.d(TAG, "Connection Failed");
}
@Override
public void onLocationChanged(Location location) {
mLastLocation = location;
}
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
if(debug) Log.d(TAG, "buildGoogleAPIClient()");
}
protected void startLocationUpdates() {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
}
क्या आप इस प्रोग्राम को एक एमुलेटर पर चला रहे हैं? – Actiwitty
अब तक आपकी गतिविधि में आपको क्या कोड मिला है? – fractalwrench
हां, एप्लिकेशन को परीक्षण के लिए एक एमुलेटर में चलाया जा रहा है। यह एपीआई/एसडीके संस्करण 23 का उपयोग कर x86 प्लेटफ़ॉर्म पर नेक्सस 5 पर आधारित है। –