آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

پروژه نوت note project با اعمال تغییرات و ایجاد مشکل thread exiting with uncaught exception

moin  11 سال پیش  11 سال پیش
0 0

با سلام خدمت همه ی دوستان عزیزم من پروژه نوت رو تغییر دادم ولی برنامه unfortunately has stopped میشه ممنون میشم راهنماییم کنید . همون پروژه نوت استاد رو در نظر بگیرید من تغییراتی دادم مثلا اول میخوام با گرفتن user , pass از کاربر شروع کنم و اگر درست بودن آنگاه وارد صفحه ی لیست ویو میشن .

به خطاهای زیر خوردم

 05-31 17:59:10.356: D/AndroidRuntime(1566): Shutting down VM
05-31 17:59:10.356: W/dalvikvm(1566): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
05-31 17:59:10.516: E/AndroidRuntime(1566): FATAL EXCEPTION: main
05-31 17:59:10.516: E/AndroidRuntime(1566): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{ans.nima.notebypost/ans.nima.notebypost.ActivityMain}: java.lang.NullPointerException
05-31 17:59:10.516: E/AndroidRuntime(1566): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
05-31 17:59:10.516: E/AndroidRuntime(1566): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
05-31 17:59:10.516: E/AndroidRuntime(1566): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-31 17:59:10.516: E/AndroidRuntime(1566): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
05-31 17:59:10.516: E/AndroidRuntime(1566): at android.os.Handler.dispatchMessage(Handler.java:99)
05-31 17:59:10.516: E/AndroidRuntime(1566): at android.os.Looper.loop(Looper.java:137)
05-31 17:59:10.516: E/AndroidRuntime(1566): at android.app.ActivityThread.main(ActivityThread.java:5103)
05-31 17:59:10.516: E/AndroidRuntime(1566): at java.lang.reflect.Method.invokeNative(Native Method)
05-31 17:59:10.516: E/AndroidRuntime(1566): at java.lang.reflect.Method.invoke(Method.java:525)
05-31 17:59:10.516: E/AndroidRuntime(1566): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
05-31 17:59:10.516: E/AndroidRuntime(1566): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-31 17:59:10.516: E/AndroidRuntime(1566): at dalvik.system.NativeStart.main(Native Method)
05-31 17:59:10.516: E/AndroidRuntime(1566): Caused by: java.lang.NullPointerException
05-31 17:59:10.516: E/AndroidRuntime(1566): at android.app.Activity.findViewById(Activity.java:1853)
05-31 17:59:10.516: E/AndroidRuntime(1566): at ans.nima.notebypost.ActivityMain.<init>(ActivityMain.java:37)
05-31 17:59:10.516: E/AndroidRuntime(1566): at java.lang.Class.newInstanceImpl(Native Method)
05-31 17:59:10.516: E/AndroidRuntime(1566): at java.lang.Class.newInstance(Class.java:1130)
05-31 17:59:10.516: E/AndroidRuntime(1566): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
05-31 17:59:10.516: E/AndroidRuntime(1566): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
05-31 17:59:10.516: E/AndroidRuntime(1566): ... 11 more
05-31 18:05:30.349: D/AndroidRuntime(1610): Shutting down VM
05-31 18:05:30.349: W/dalvikvm(1610): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
05-31 18:05:30.427: E/AndroidRuntime(1610): FATAL EXCEPTION: main
05-31 18:05:30.427: E/AndroidRuntime(1610): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{ans.nima.notebypost/ans.nima.notebypost.ActivityMain}: java.lang.NullPointerException
05-31 18:05:30.427: E/AndroidRuntime(1610): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
05-31 18:05:30.427: E/AndroidRuntime(1610): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
05-31 18:05:30.427: E/AndroidRuntime(1610): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-31 18:05:30.427: E/AndroidRuntime(1610): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
05-31 18:05:30.427: E/AndroidRuntime(1610): at android.os.Handler.dispatchMessage(Handler.java:99)
05-31 18:05:30.427: E/AndroidRuntime(1610): at android.os.Looper.loop(Looper.java:137)
05-31 18:05:30.427: E/AndroidRuntime(1610): at android.app.ActivityThread.main(ActivityThread.java:5103)
05-31 18:05:30.427: E/AndroidRuntime(1610): at java.lang.reflect.Method.invokeNative(Native Method)
05-31 18:05:30.427: E/AndroidRuntime(1610): at java.lang.reflect.Method.invoke(Method.java:525)
05-31 18:05:30.427: E/AndroidRuntime(1610): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
05-31 18:05:30.427: E/AndroidRuntime(1610): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-31 18:05:30.427: E/AndroidRuntime(1610): at dalvik.system.NativeStart.main(Native Method)
05-31 18:05:30.427: E/AndroidRuntime(1610): Caused by: java.lang.NullPointerException
05-31 18:05:30.427: E/AndroidRuntime(1610): at android.app.Activity.findViewById(Activity.java:1853)
05-31 18:05:30.427: E/AndroidRuntime(1610): at ans.nima.notebypost.ActivityMain.<init>(ActivityMain.java:37)
05-31 18:05:30.427: E/AndroidRuntime(1610): at java.lang.Class.newInstanceImpl(Native Method)
05-31 18:05:30.427: E/AndroidRuntime(1610): at java.lang.Class.newInstance(Class.java:1130)
05-31 18:05:30.427: E/AndroidRuntime(1610): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
05-31 18:05:30.427: E/AndroidRuntime(1610): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
05-31 18:05:30.427: E/AndroidRuntime(1610): ... 11 more
05-31 18:06:48.737: I/Process(1610): Sending signal. PID: 1610 SIG: 9
05-31 18:14:51.107: D/AndroidRuntime(1658): Shutting down VM
05-31 18:14:51.208: W/dalvikvm(1658): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
05-31 18:14:51.267: E/AndroidRuntime(1658): FATAL EXCEPTION: main
05-31 18:14:51.267: E/AndroidRuntime(1658): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{ans.nima.notebypost/ans.nima.notebypost.ActivityMain}: java.lang.NullPointerException
05-31 18:14:51.267: E/AndroidRuntime(1658): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
05-31 18:14:51.267: E/AndroidRuntime(1658): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
05-31 18:14:51.267: E/AndroidRuntime(1658): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-31 18:14:51.267: E/AndroidRuntime(1658): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
05-31 18:14:51.267: E/AndroidRuntime(1658): at android.os.Handler.dispatchMessage(Handler.java:99)
05-31 18:14:51.267: E/AndroidRuntime(1658): at android.os.Looper.loop(Looper.java:137)
05-31 18:14:51.267: E/AndroidRuntime(1658): at android.app.ActivityThread.main(ActivityThread.java:5103)
05-31 18:14:51.267: E/AndroidRuntime(1658): at java.lang.reflect.Method.invokeNative(Native Method)
05-31 18:14:51.267: E/AndroidRuntime(1658): at java.lang.reflect.Method.invoke(Method.java:525)
05-31 18:14:51.267: E/AndroidRuntime(1658): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
05-31 18:14:51.267: E/AndroidRuntime(1658): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-31 18:14:51.267: E/AndroidRuntime(1658): at dalvik.system.NativeStart.main(Native Method)
05-31 18:14:51.267: E/AndroidRuntime(1658): Caused by: java.lang.NullPointerException
05-31 18:14:51.267: E/AndroidRuntime(1658): at android.app.Activity.findViewById(Activity.java:1853)
05-31 18:14:51.267: E/AndroidRuntime(1658): at ans.nima.notebypost.ActivityMain.<init>(ActivityMain.java:39)
05-31 18:14:51.267: E/AndroidRuntime(1658): at java.lang.Class.newInstanceImpl(Native Method)
05-31 18:14:51.267: E/AndroidRuntime(1658): at java.lang.Class.newInstance(Class.java:1130)
05-31 18:14:51.267: E/AndroidRuntime(1658): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
05-31 18:14:51.267: E/AndroidRuntime(1658): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
05-31 18:14:51.267: E/AndroidRuntime(1658): ... 11 more
05-31 18:14:54.747: I/Process(1658): Sending signal. PID: 1658 SIG: 9

package ans.nima.notebypost;


import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;


@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public class ActivityMain extends ActivityEnhanced {

//private ArrayList<StructTask>netTasks = new ArrayList<StructTask>();

//private ArrayAdapter adapter;

EditText edtUsername=(EditText)findViewById(R.id.edtUsername);
EditText edtPassword=(EditText)findViewById(R.id.edtPassword);
Button btnLogin=(Button)findViewById(R.id.btnLogin);




@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


StrictMode.ThreadPolicy policy=new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);

btnLogin.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {

ArrayList<NameValuePair> params=new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("puser", ""+edtUsername));
if(Commands.checkData(params))
{
Intent intent=new Intent(G.currentActivity,ActivityPatient.class);
intent.putExtra("PUSER",edtUsername+"" );

G.currentActivity.startActivity(intent);


}
}
});

}

}










package ans.nima.notebypost;


import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;


public class ActivityPatient extends ActivityEnhanced {

//private ArrayList<StructTask>netTasks = new ArrayList<StructTask>();

String puser="";
private ArrayAdapter adapter;

@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
adapter.notifyDataSetChanged();
}


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_patient);

Bundle extras=getIntent().getExtras();
if(extras != null)
{
puser=extras.getString("PUSER");

G.puser=puser;


ArrayList<NameValuePair> params=new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("username", ""+puser));
Commands.recpid(params);


}


final ListView lstContent=(ListView) findViewById(R.id.lstContent);
adapter=new AdapterNote(G.docts);
lstContent.setAdapter(adapter);
Commands.readData();
adapter.notifyDataSetChanged();

}

}











package ans.nima.notebypost;

import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class AdapterNote extends ArrayAdapter<StructDoc> {



public AdapterNote(ArrayList<StructDoc> array)
{
super(G.context,R.layout.adapter_notes,array);
}
private static class ViewHolder
{
public TextView txtId;
public TextView txtName;
public TextView txtDay;
public TextView txtTime;
public TextView txtCap;
public CheckBox chkRes;
public ViewGroup layoutRoot;

StructDoc docs=new StructDoc();
StructPatient patient=new StructPatient();

public ViewHolder(View view)
{
txtId=(TextView)view.findViewById(R.id.txtId);
txtName=(TextView)view.findViewById(R.id.txtName);
txtTime=(TextView)view.findViewById(R.id.txtTime);
txtCap=(TextView)view.findViewById(R.id.txtCap);
txtDay=(TextView)view.findViewById(R.id.txtDay);
chkRes=(CheckBox)view.findViewById(R.id.chkRes);
layoutRoot=(ViewGroup)view.findViewById(R.id.layoutRoot);


}
public void fill(final ArrayAdapter<StructDoc>adapter,final StructDoc item,final int position)
{

// TODO Auto-generated method stub
txtId.setText(item.id);
txtName.setText(item.name);
txtDay.setText(item.day);
txtTime.setText(item.time);
txtCap.setText(item.cap);


/* layoutRoot.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent =new Intent(G.currentActivity,ActivityEdit.class);
intent.putExtra("POSITION", position);
G.currentActivity.startActivity(intent);
}
});
*/
chkRes.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View view) {
// TODO Auto-generated method stub
CheckBox checkBox =(CheckBox)view;

if(checkBox.isChecked())
{
txtName.setTextColor(Color.GREEN);
ArrayList<NameValuePair> params=new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("did", ""+docs.id));
params.add(new BasicNameValuePair("day",docs.day));
params.add(new BasicNameValuePair("time",docs.time));
params.add(new BasicNameValuePair("pid", ""+G.pid));
Commands.insertData(params);
}
else
{
txtName.setTextColor(Color.WHITE);
}
}

});
if(chkRes.isChecked())
{
txtName.setTextColor(Color.GREEN);
}else
{
txtName.setTextColor(Color.WHITE);
}
}


}//class ViewHolder
@Override
public View getView(int position ,View convertView,ViewGroup parent)
{
ViewHolder holder;

StructDoc item=getItem(position);
if(convertView == null)
{
convertView = G.inflater.inflate(R.layout.adapter_notes,parent,false);
holder=new ViewHolder(convertView);
convertView.setTag(holder);
}else
{
holder=(ViewHolder)convertView.getTag();
}
holder.fill(this, item, position);
return convertView;

}
}












package ans.nima.notebypost;

import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Commands {

public static String checkres="";
public static void updateData(final ArrayList<NameValuePair>params)
{

new Thread(new Runnable()
{

@Override
public void run() {
// TODO Auto-generated method stub
Webservice.readUrl("http://192.168.1.3/note/webservice.php?action=update",params);
}
}).start();
}

public static void insertData(final ArrayList<NameValuePair>params)
{

new Thread(new Runnable()
{

@Override
public void run() {
// TODO Auto-generated method stub
Webservice.readUrl("http://192.168.1.3/hospital/Android/insert.php",params);
}
}).start();

}

public static void readData()
{

Thread t1=new Thread(new Runnable()
{

@Override
public void run() {
// TODO Auto-generated method stub
String result=Webservice.readUrl("http://192.168.1.3/hospital/Android/select.php",null);
if(result !=null )
{
//Log.i("LOG",result);
try
{
G.docts.clear();
JSONArray docts= new JSONArray(result);
for(int i=0;i<docts.length();i++)
{
JSONObject object=docts.getJSONObject(i);
StructDoc doc =new StructDoc();
doc.id=object.getInt("did");
doc.name=object.getString("dname");
doc.day=object.getString("day");
doc.time=object.getString("stime");
doc.cap=object.getInt("num");
//Log.i("LOG",object.getString("task_title"));
G.docts.add(doc);
}
}
catch(JSONException e)
{
e.printStackTrace();
}
}
}

});
t1.start();
}
public static boolean checkData(final ArrayList<NameValuePair>params)
{

new Thread(new Runnable()
{

@Override
public void run() {
// TODO Auto-generated method stub
checkres="";
checkres=Webservice.readUrl("http://192.168.1.3/hospital/Android/login.php",params);
}
}).start();
if(checkres != null)
{
return true;
}
else
return false;

}

public static void recpid(final ArrayList<NameValuePair>params)
{

new Thread(new Runnable()
{

@Override
public void run() {
// TODO Auto-generated method stub

String result=Webservice.readUrl("http://192.168.1.3/hospital/Android/recpid.php",params);
if(result !=null )
{
//Log.i("LOG",result);
try
{
G.patient.clear();
JSONArray patients= new JSONArray(result);
for(int i=0;i<patients.length();i++)
{
JSONObject object=patients.getJSONObject(i);
StructPatient pat =new StructPatient();
pat.pid=object.getInt("pid");
pat.pname=object.getString("pname");

pat.puser=G.puser;
G.pid=pat.pid;
//Log.i("LOG",object.getString("task_title"));
G.patient.add(pat);
}
}
catch(JSONException e)
{
e.printStackTrace();
}
}
}
}).start();

}

}





















 برای این سوال پاسخی وجود ندارد.

پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .