Run Android app in different devices -
i run application in 2 different android devices. first arnova 9 g2 tablet , second sony xperia p. in arnova tablet application executed successfully, in sony xperia p phone, logcat displays me following error:
/data/data/com.example.androidjnetpcaptest/interfaces: open failed: eacces (permission denied) fatal exception: main java.lang.nullpointerexception @ com.example.androidjnetpcaptest.interfacesfragment.oncreateview(interfacesfragment.java:35)
my manifest xml file is:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.androidjnetpcaptest" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="14" android:targetsdkversion="19" /> <uses-permission android:name="android.permission.change_wifi_state" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.read_external_storage"/> <uses-permission android:name="android.pemission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".splashscreenactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".mainactivity" android:label="@string/app_name" android:screenorientation="portrait"> <intent-filter> <action android:name="android.intent.action.default" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".informationsactivity" android:theme="@android:style/theme.holo" android:label="@string/app_name" android:screenorientation="portrait"> <intent-filter> <action android:name="android.intent.action.default" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> </application> </manifest>
and interfacesfragment class is:
public class interfacesfragment extends fragment { private scanner inputstream = null; private textview interfacestextview = null; @override public view oncreateview( layoutinflater inflater, viewgroup container, bundle savedinstancestate ) { try { inputstream = new scanner( new fileinputstream( "/data/data/com.example.androidjnetpcaptest/interfaces" ) ); } catch ( filenotfoundexception e ) { log.e( "interfacesfragment_error: ", e.getmessage() ); } string lines = ""; while ( inputstream.hasnextline() ) { lines = lines + inputstream.nextline() + "\n"; } inputstream.close(); final progressdialog ringprogressdialog = progressdialog.show( getactivity(), "please wait ...", "finding interfaces ...", true ); ringprogressdialog.setcancelable( true ); new thread(new runnable() { @override public void run() { try { thread.sleep( 4000 ); } catch ( exception e ) { } ringprogressdialog.dismiss(); } }).start(); view rootview = inflater.inflate(r.layout.interfaces, container, false); interfacestextview = ( textview ) rootview.findviewbyid( r.id.interfacestextview ); interfacestextview.settext( lines ); interfacestextview.setmovementmethod( new scrollingmovementmethod() ); return rootview; } }
the trouble use of absolute path /data/data/com.example. androidjnetpcaptest/interfaces
. should not assume data location app. apps can moved external storage , since ics system supports multiple users (people) app gets different storage per user. instead, use context.getfilesdir()
app-private location files can created , stored.
you not need special permissions read/write space.
Comments
Post a Comment