Android Jetty fatal exception - java

I am working on an Android web server with Jetty. There are two files: MainActivity.java and Servlet.java which contains my main server class ExampleServlet. Files are shown below:
Servlet.java
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpStatus;
class ExampleServlet extends HttpServlet {
#Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setStatus(HttpStatus.OK_200);
resp.getWriter().println("Hello World");
}
}
MainActivity.java
package com.example.joey.myproject;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import com.example.joey.myproject.ExampleServlet;
import javax.servlet.Servlet;
public class MainActivity extends AppCompatActivity{
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Server server = new Server(7070);
ServletContextHandler handler = new ServletContextHandler(server, "/example");
handler.addServlet(ExampleServlet.class, "/");
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
When I install APK and run, the app is crashing. And I am getting this error on logcat:
08-28 10:07:02.869 29531-29531/com.example.joey.myproject E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at org.eclipse.jetty.server.HttpConfiguration.<init>(HttpConfiguration.java:61)
at org.eclipse.jetty.server.HttpConnectionFactory.<init>(HttpConnectionFactory.java:40)
at org.eclipse.jetty.server.ServerConnector.<init>(ServerConnector.java:96)
at org.eclipse.jetty.server.Server.<init>(Server.java:113)
at com.example.joey.myproject.MainActivity.onCreate(MainActivity.java:125)
at android.app.Activity.performCreate(Activity.java:5247)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2225)
at android.app.ActivityThread.access$600(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1301)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5071)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
at org.eclipse.jetty.util.BufferUtil.toBuffer(BufferUtil.java:850)
at org.eclipse.jetty.http.HttpScheme.<init>(HttpScheme.java:52)
at org.eclipse.jetty.http.HttpScheme.<clinit>(HttpScheme.java:32)
at org.eclipse.jetty.server.HttpConfiguration.<init>(HttpConfiguration.java:61) 
at org.eclipse.jetty.server.HttpConnectionFactory.<init>(HttpConnectionFactory.java:40) 
at org.eclipse.jetty.server.ServerConnector.<init>(ServerConnector.java:96) 
at org.eclipse.jetty.server.Server.<init>(Server.java:113) 
at com.example.joey.myproject.MainActivity.onCreate(MainActivity.java:125) 
at android.app.Activity.performCreate(Activity.java:5247) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2225) 
at android.app.ActivityThread.access$600(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1301) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:153) 
at android.app.ActivityThread.main(ActivityThread.java:5071) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 
at dalvik.system.NativeStart.main(Native Method) 
What should I do?

I guess you are running your code in a jvm lower than 7 which does not contain the Java nio package.
So you have to upgrade your jvm to Java 1.7 or higher
https://docs.oracle.com/javase/7/docs/api/java/nio/charset/StandardCharsets.html

Related

Check File Extension in android

i made a small method to check whether defined folder has files with a specific extension or not. I m getting null point exception on run.pls help to find mistake.method is checking .mp4 files and returning true if found and message is displayed.
Here is Code:
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView filecheck;
filecheck = (TextView) findViewById(R.id.filecheck);
filecheck.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (accept()) {
Toast.makeText(MainActivity.this, "Files Found", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "Files Not Found", Toast.LENGTH_SHORT).show();
}
}
});
}
public boolean accept() {
final File pathname = new File("/sdcard/test/");
String files[] = pathname.list();
System.out.println(files.length);
for (String s : files) {
if (s.contains(".mp4")) {
System.out.println(s);
return true;
}
return false;
}
return false;
}
}
Here is exception:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: jss.testmethods, PID: 23659
java.lang.NullPointerException
at jss.testmethods.MainActivity.accept(MainActivity.java:38)
at jss.testmethods.MainActivity$1.onClick(MainActivity.java:24)
at android.view.View.performClick(View.java:4478)
at android.view.View$PerformClick.run(View.java:18698)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
i was expecting simple error, i missed to add permission for read storage. it is working now.

My Android App crashes and gives illigale access exception, i've tried to implement a tcp service to communicate with my server

I am trying to write a service to communicate with a tcp server on www.herbrich.org:2147
But my app keep on crashing every time i run it. Here is my full code from the service class.
ServiceClass:
package org.herbrich.katana;
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Random;
/**
* Created by Administrator on 16.04.2015.
*/
public class LocalService extends Service{
LocalService()
{
new Thread(new ClientThread()).start();
}
//JenniferHerbrich Network Ansi Declares
private Socket socket;
private static final int SERVERPORT;
private static final String SERVER_IP;
static {
SERVER_IP = "10.141.0.151";
SERVERPORT = 2147;
}
// Binder given to clients
private final IBinder mBinder = new LocalBinder();
// Random number generator
private final Random mGenerator = new Random();
/**
* Class used for the client Binder. Because we know this service always
* runs in the same process as its clients, we don't need to deal with IPC.
*/
public class LocalBinder extends Binder {
LocalService getService() {
// Return this instance of LocalService so clients can call public method
return LocalService.this;
}
}
#Override
public IBinder onBind(Intent intent) {
return mBinder;
}
/** method for clients */
public int getRandomNumber() {
return mGenerator.nextInt(100);
}
public String communicateWithEvelin(String EvelinValue)
{
try
{
BufferedReader input;
PrintWriter out = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(socket.getOutputStream())),
true);
out.println(EvelinValue);
out.flush();
input = new BufferedReader(new InputStreamReader(this.socket.getInputStream()));
return input.readLine();
}
catch(Exception e)
{
return "ERROR";
}
}
class ClientThread implements Runnable {
#Override
public void run() {
try {
InetAddress serverAddr = InetAddress.getByName(SERVER_IP);
socket = new Socket(serverAddr, SERVERPORT);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
I think i've some problem with the multithreading call inside the constructor method. The debug console gives me illegalAccessExceptions..
LogCat:
04-15 18:52:08.632 9182-9182/org.herbrich.katana E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate service org.herbrich.katana.LocalService: java.lang.IllegalAccessException: access to constructor not allowed
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2599)
at android.app.ActivityThread.access$1700(ActivityThread.java:158)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1384)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5365)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalAccessException: access to constructor not allowed
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2596)
            at android.app.ActivityThread.access$1700(ActivityThread.java:158)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1384)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:176)
            at android.app.ActivityThread.main(ActivityThread.java:5365)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
            at dalvik.system.NativeStart.main(Native Method)
04-15 18:52:08.640 9182-9197/org.herbrich.katana E/TCP Client﹕ C: Connecting...
your ClientThread class must be public, and has a public zero-argument constructor, and that the constructor chains to the superclass' constructor.

java.lang.IllegalStateException In Android

I try to send a string from the java desktop program to android using socket connection. When the user click a button in the android application it will displays the message from the java app. When i click the Button it displays java.lang.IllegalStateException.I can found many questions like this in this site but noone dont match my requirement.
Android Code
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity
{
private Socket client;
private InputStreamReader isr;
private BufferedReader bf;
private String message;
private AsyncClass ac;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
class AsyncClass extends AsyncTask<Void, Void,Void>
{
protected Void doInBackground(Void... params)
{
hardtask();
return null;
}
public void hardtask()
{
try
{
client=new Socket("10.0.2.2",7777);
isr=new InputStreamReader(client.getInputStream());
bf=new BufferedReader(isr);
message=bf.readLine();
Log.v("Message", message);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void onClick(View view)
{
ac.execute();
}
#Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Logcat
02-27 02:02:02.191: D/gralloc_goldfish(1445): Emulator without GPU emulation detected.
02-27 02:02:05.541: D/AndroidRuntime(1445): Shutting down VM
02-27 02:02:05.651: W/dalvikvm(1445): threadid=1: thread exiting with uncaught exception (group=0xb1a7eb90)
02-27 02:02:05.711: E/AndroidRuntime(1445): FATAL EXCEPTION: main
02-27 02:02:05.711: E/AndroidRuntime(1445): Process: andro.androreply, PID: 1445
02-27 02:02:05.711: E/AndroidRuntime(1445): java.lang.IllegalStateException: Could not execute method of the activity
02-27 02:02:05.711: E/AndroidRuntime(1445): at android.view.View$1.onClick(View.java:3814)
02-27 02:02:05.711: E/AndroidRuntime(1445): at android.view.View.performClick(View.java:4424)
02-27 02:02:05.711: E/AndroidRuntime(1445): at android.view.View$PerformClick.run(View.java:18383)
02-27 02:02:05.711: E/AndroidRuntime(1445): at android.os.Handler.handleCallback(Handler.java:733)
02-27 02:02:05.711: E/AndroidRuntime(1445): at android.os.Handler.dispatchMessage(Handler.java:95)
02-27 02:02:05.711: E/AndroidRuntime(1445): at android.os.Looper.loop(Looper.java:137)
02-27 02:02:05.711: E/AndroidRuntime(1445): at android.app.ActivityThread.main(ActivityThread.java:4998)
02-27 02:02:05.711: E/AndroidRuntime(1445): at java.lang.reflect.Method.invokeNative(Native Method)
02-27 02:02:05.711: E/AndroidRuntime(1445): at java.lang.reflect.Method.invoke(Method.java:515)
02-27 02:02:05.711: E/AndroidRuntime(1445): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
02-27 02:02:05.711: E/AndroidRuntime(1445): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
02-27 02:02:05.711: E/AndroidRuntime(1445): at dalvik.system.NativeStart.main(Native Method)
02-27 02:02:05.711: E/AndroidRuntime(1445): Caused by: java.lang.reflect.InvocationTargetException
02-27 02:02:05.711: E/AndroidRuntime(1445): at java.lang.reflect.Method.invokeNative(Native Method)
02-27 02:02:05.711: E/AndroidRuntime(1445): at java.lang.reflect.Method.invoke(Method.java:515)
02-27 02:02:05.711: E/AndroidRuntime(1445): at android.view.View$1.onClick(View.java:3809)
02-27 02:02:05.711: E/AndroidRuntime(1445): ... 11 more
02-27 02:02:05.711: E/AndroidRuntime(1445): Caused by: java.lang.NullPointerException
02-27 02:02:05.711: E/AndroidRuntime(1445): at andro.androreply.MainActivity.onClick(MainActivity.java:52)
02-27 02:02:05.711: E/AndroidRuntime(1445): ... 14 more
Java Code
import java.io.*;
import java.net.*;
public class Server
{
private static String msg="Hai";
private static Socket client;
private static PrintWriter pw;
private static ServerSocket socket;
public static void main(String args[])
{
try {
socket=new ServerSocket(7777);
client= socket.accept(); //Server socket
pw=new PrintWriter(client.getOutputStream(),true);
pw.write(msg);
pw.flush();
pw.close();
client.close();
}
catch (IOException e)
{
System.out.println("Could not listen on port: 7676");
}
}
}
Anyone can help me to resolve this. Thanks in advance...
You need to instantiate ac and then call execute(). execute() is method of AsyncTask.
ac = new AsyncClass();
I see you have
private AsyncClass ac;
And
public void onClick(View view)
{
ac.execute();
}
But you have not instantiated ac anywhere
You have a variable AsyncClass ac, but you're not actually initialising it. In your onClick(), instead of:
ac.execute();
do:
new AsyncClass.execute();
or initialise your ac variable in onCreate() first with:
ac = new AsyncClass();

Having trouble passing variable to be displayed on a screen on android

I am having trouble with developing my Android application, I am currently using Eclipse and a Phidget RFID. My aim is to display the ID of the RFID in a piece of text on the Android device.
I have managed to display the ID through a println in the following pieces of code.
package myFood.myFood;
import com.phidgets.*;
import com.phidgets.event.*;
public class RFID {
static String x ="NULL";
public static final Object main(String args[]) throws Exception {
RFIDPhidget rfid;
rfid = new RFIDPhidget();
rfid.openAny();
//Begin the TagGained event, allowing for users to read the RFID values
rfid.addTagGainListener(new TagGainListener()
{
public void tagGained(TagGainEvent oe)
{
Object y = (oe.getValue());
x= y.toString();
}
});
long StartTime,RunTime;
StartTime=System.currentTimeMillis();
do{
RunTime=System.currentTimeMillis();
if (x.equals("NULL")) {
//Continue waiting for input
}
else
StartTime = 10000; //Overload the result so the loop ends
}
while (RunTime-StartTime<5000);
rfid.close();
return x;
}
}
and then.
package myFood.myFood;
public class RFIDresult {
public static final Object main(String args[]) throws Exception {
System.out.println("Results");
Object x = RFID.main(args);
System.out.println(x);
return x;
}
}
However I want the ID to be displayed in a piece of text so I tried to develop the second piece of code into Android.
package myFood.myFood;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class AddFood extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.addfood);
Button mybutton = (Button) findViewById(R.id.Button1);
mybutton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String[] args = null;
Object x = null;
try {
x = RFID.main(args);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TextView mytext=(TextView)findViewById(R.id.widget96);
mytext.setText((CharSequence) x);
}
});
}
}
And this just generates a force close. I am a bit of a novice at this and will appreciate all the advice I get.
LogCat Report;
ERROR/AndroidRuntime(519): FATAL EXCEPTION: main
ERROR/AndroidRuntime(519): java.lang.ExceptionInInitializerError
ERROR/AndroidRuntime(519): at myFood.myFood.RFID.main(RFID.java:9)
ERROR/AndroidRuntime(519): at myFood.myFood.AddFood$1.onClick(AddFood.java:26)<br/>
ERROR/AndroidRuntime(519): at android.view.View.performClick(View.java:2408)
ERROR/AndroidRuntime(519): at android.view.View$PerformClick.run(View.java:8816)
ERROR/AndroidRuntime(519): at android.os.Handler.handleCallback(Handler.java:587)
ERROR/AndroidRuntime(519): at android.os.Handler.dispatchMessage(Handler.java:92)
ERROR/AndroidRuntime(519): at android.os.Looper.loop(Looper.java:123)
ERROR/AndroidRuntime(519): at android.app.ActivityThread.main(ActivityThread.java:4627)
ERROR/AndroidRuntime(519): at java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(519): at java.lang.reflect.Method.invoke(Method.java:521)
ERROR/AndroidRuntime(519): at om.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
ERROR/AndroidRuntime(519): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
ERROR/AndroidRuntime(519): at dalvik.system.NativeStart.main(Native Method)
ERROR/AndroidRuntime(519): Caused by: java.lang.ExceptionInInitializerError: Library phidget21 not found
ERROR/AndroidRuntime(519): Could not locate the Phidget C library (libphidget21.so).
ERROR/AndroidRuntime(519): Make sure it is installed, and add it's path to LD_LIBRARY_PATH.
ERROR/AndroidRuntime(519): at com.phidgets.Phidget.<clinit>(Phidget.java:34)
ERROR/AndroidRuntime(519): ... 13 more
You need to get myText from 'view' parameter. Try this:
TextView mytext=(TextView)**view**.findViewById(R.id.widget96);

Can't load a static file on Android 2.1

I need to load a text file which is placed in res/raw directory into memory. Here is my code:
package com.ggd543.android;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TextView;
import java.io.IOException;
import java.io.InputStream;
public class FileActivity extends Activity {
/**
* Called when the activity is first created.
*/
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
loadText();
}
private void loadText() {
// InputStream is = Resources.getSystem().openRawResource(R.raw.text);
InputStream is = getResources().openRawResource(R.raw.text);
try {
byte[] buf = new byte[is.available()];
is.read(buf, 0, buf.length);
((TextView) findViewById(R.layout.main)).setText(new String(buf, "UTF-8"));
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
}
When I deploy the .apk on emulator and start it up, I got the following error:
12-25 14:33:38.096: ERROR/AndroidRuntime(3077): Uncaught handler: thread main exiting due to uncaught exception
12-25 14:33:38.106: ERROR/AndroidRuntime(3077): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ggd543.android/com.ggd543.android.FileActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030000
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
at android.app.ActivityThread.access$2200(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030000
at android.content.res.Resources.getValue(Resources.java:891)
at android.content.res.Resources.openRawResource(Resources.java:816)
at android.content.res.Resources.openRawResource(Resources.java:798)
at com.ggd543.android.FileActivity.loadText(FileActivity.java:23)
at com.ggd543.android.FileActivity.onCreate(FileActivity.java:19)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
... 11 more
Could anyone give me suggestion ?
Thx
Move the file to the assets folder.
Then retrieve the stream like this InputStream is = getAssets().open("fileName");
if you have assets/mytxtfile.txt
then fileName = "mytxtfile.txt"
What is the file name ? coz as per odcs, if you've a file called 'abcd.txt' in /res/raw, you're suppose to open it using resource ID "R.raw.abcd", i.e. excluding the 3 digit extension.

Categories