java - app crashes on real device due to udev rule error -


error shown follows:

com.android.ddmlib.adbcommandrejectedexception: insufficient permissions device: verify enter code here udev rules. see [http://developer.android.com/tools/device.html] more information. error while installing apk

the java code mainactivity shown below:

    import android.manifest;     import android.location.location;     import android.support.v4.app.activitycompat;     import android.support.v7.app.appcompatactivity;     import android.os.bundle;     import android.text.textutils;     import android.view.view;     import android.widget.button;     import android.widget.edittext;     import android.widget.textview;      public class mainactivity extends appcompatactivity {      edittext t1;     edittext t2;     textview textview;     button calc;     float lat1;     float lon1;           @override         protected void oncreate(bundle savedinstancestate) {             super.oncreate(savedinstancestate);             setcontentview(r.layout.activity_main2);               t1 = (edittext) findviewbyid(r.id.edittext1);             t2 = (edittext) findviewbyid(r.id.edittext2);             calc = (button) findviewbyid(r.id.button);             textview = (textview) findviewbyid(r.id.textview);               activitycompat.requestpermissions(mainactivity.this,new string[]          {manifest.permission.access_fine_location},123);             calc.setonclicklistener(new view.onclicklistener() {                 @override                 public void onclick(view view) {                       if(textutils.isempty(t1.gettext()))                     {                         lat1 = 0;                     }                     else                     {                        lat1  = float.parsefloat(t1.gettext().tostring());                     }                      if(textutils.isempty(t2.gettext()))                     {                         lon1 =0;                     }                     else                     {                         lon1 = float.parsefloat(t2.gettext().tostring());                     }                       float latt1 = (float) math.toradians(lat1);                     float lng1 = (float) math.toradians(lon1);                       geotracker tracker = new  geotracker(getapplicationcontext());                      location loc = tracker.getlocation();                      if(loc !=null) {                         float latt2 = (float) loc.getlatitude();                         float lng2 = (float) loc.getlongitude();                          float dlon = lng2 - lng1;                         float dlat = latt2 - latt1;                          float = (float) (math.pow((math.sin(dlat / 2)), 2) + math.cos(latt1) * math.cos(latt2) * math.pow(math.sin(dlon / 2), 2));                          float c = (float) (2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)));                          float dist = (float) (6371 * c);                         textview.settext("                     distance :"+ float.tostring(dist));                      }                  }             });               }          } 

the geotracker class shown below:

            package com.example.vishnu.location;              import android.manifest;             import android.content.context;             import android.content.intent;             import android.content.pm.packagemanager;             import android.location.location;             import android.location.locationlistener;             import android.location.locationmanager;             import android.os.bundle;             import android.provider.settings;             import android.support.v4.content.contextcompat;             import android.widget.toast;              /**              * created vishnu-c on 8/13/17.             */              public class geotracker implements locationlistener {                context context;              public geotracker(context c){                context = c;             }              public location getlocation(){                 if(contextcompat.checkselfpermission(context, manifest.permission.access_fine_location) != packagemanager.permission_granted){                     toast.maketext(context,"permission not granted",toast.length_short).show();                 }                 locationmanager locationmanager =(locationmanager)context.getsystemservice(context.location_service);                 boolean isgpsenabled = locationmanager.isproviderenabled(locationmanager.gps_provider);                 if(isgpsenabled){                     locationmanager.requestlocationupdates(locationmanager.gps_provider,6000,6,this);                     location loc = locationmanager.getlastknownlocation(locationmanager.gps_provider);                      return loc;                 }                 else{                     toast.maketext(context,"please enable gps",toast.length_short).show();                   }                 return  null;             }              @override             public void onlocationchanged(location location) {              }              @override             public void onstatuschanged(string s, int i, bundle bundle) {              }              @override             public void onproviderenabled(string s) {              }              @override             public void onproviderdisabled(string s) {                 intent intent = new intent(settings.action_location_source_settings);              }         } 

the xml code shown below:

            <?xml version="1.0" encoding="utf-8"?>             <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"             xmlns:tools="http://schemas.android.com/tools"             android:layout_width="match_parent"             android:layout_height="match_parent"             tools:context="com.example.vishnu.location.main2activity">           <button             android:id="@+id/button"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_centerhorizontal="true"             android:layout_centervertical="true"             android:text="calculate"             tools:layout_editor_absolutex="147dp"             tools:layout_editor_absolutey="272dp" />          <edittext             android:id="@+id/edittext1"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_alignparentleft="true"             android:layout_alignparentstart="true"             android:layout_alignparenttop="true"             android:layout_marginleft="70dp"             android:layout_marginstart="70dp"             android:layout_margintop="91dp"             android:ems="10"             android:inputtype="numbersigned|numberdecimal"             android:hint="enter target lattitude" />         <edittext             android:id="@+id/edittext2"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_alignend="@+id/edittext1"             android:layout_alignright="@+id/edittext1"             android:layout_below="@+id/edittext1"             android:layout_margintop="15dp"             android:ems="10"             android:inputtype="numbersigned|numberdecimal"             android:hint="enter target longitude" />          <textview             android:id="@+id/textview"             android:layout_width="match_parent"             android:layout_height="50dp"             android:layout_alignparenttop="true"             android:layout_margintop="32dp" />          </relativelayout> 

android manifest shown below:

     <?xml version="1.0" encoding="utf-8"?>     <manifest xmlns:android="http://schemas.android.com/apk/res/android"         package="com.example.vishnu.location">          <uses-permission android:name="android.permission.access_fine_location" />          <application             android:allowbackup="true"             android:icon="@mipmap/ic_launcher"             android:label="@string/app_name"             android:roundicon="@mipmap/ic_launcher_round"             android:supportsrtl="true"             android:theme="@style/apptheme">             <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> 


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -