İş Tecrubesi
Eğitim Geçmişi
Sertifikalar & Başarılar
Kullanıcıya ait test sonucu bulunmamaktadır.
Dil Becerileri
Son Forum Aktiviteleri
3Android giriş yapan kişiyi anlama(php session mantığı)
mehaba arkadaslar yaptigim uygulamada kullanici giris yapiyor fakat kimin girdigi anlasilmiyor yani benim kisinin id sini cekerek ona özel sayfa olusturmam gerekli veritani olarak mysql kullaniyorum.Nasil bir mantik yurutmaliyim yardimci olurmusunuz?
checkbox kullanımı
Merhabalar
Checkbox kutularının hepsini isaretlemeden program kayit yapmiyor.Yani hepsini isaretleyip kayit ettikten sonra tek isaretleyip kayit yapabiliyorum.Hatami bulabiilirmisiniz?
package com.ugurkrky.uygulama; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.Toast; import com.android.volley.AuthFailureError; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; import java.util.HashMap; import java.util.Map; public class mesajkaydet extends AppCompatActivity { Button mesajkayit; EditText mesaj; RequestQueue requestQueue; String insertUrl = ("http://10.0.3.2/msosyal/mesajkayit.php"); String sonuc1,sonuc2,sonuc3,sonuc4; CheckBox cb1,cb1i,cb2,cb2i; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mesajkaydet); cb1=(CheckBox)findViewById(R.id.bir); cb1i=(CheckBox)findViewById(R.id.birio); cb2=(CheckBox)findViewById(R.id.iki); cb2i=(CheckBox)findViewById(R.id.ikiio); cb1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(cb1.isChecked()) { sonuc1="1";} } }); cb1i.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(cb1i.isChecked()) { sonuc2="2";} } }); cb2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(cb2.isChecked()) { sonuc3="3";} } }); cb2i.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(cb2i.isChecked()) {sonuc4="4";} } }); mesaj=(EditText)findViewById(R.id.mesajalan); mesajkayit=(Button) findViewById(R.id.mesajgonder); requestQueue = Volley.newRequestQueue(getApplicationContext()); assert mesajkayit != null; mesajkayit.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { StringRequest request = new StringRequest(Request.Method.POST, insertUrl, new Response.Listener<String>() { @Override public void onResponse(String response) { Toast.makeText(getApplicationContext(), "Gönderildi", Toast.LENGTH_SHORT).show(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(getApplicationContext(), "Bağlantı hatası", Toast.LENGTH_SHORT).show(); } }) { @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String,String> parameters = new HashMap<String, String>(); parameters.put("mesaj",mesaj.getText().toString()); parameters.put("cb1", sonuc1); parameters.put("cb1i", sonuc2); parameters.put("cb2", sonuc3); parameters.put("cb2i",sonuc4.toString()); return parameters; } }; requestQueue.add(request); } }); } }
Android uygulama unfortunately has stopped hatası
Şu hataları alıyorum:
05-17 04:51:04.061 4436-4436/com.ugurkrky.uygulama E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ugurkrky.uygulama/com.ugurkrky.uygulama.ogrenciekle}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.ugurkrky.uygulama.ogrenciekle.onCreate(ogrenciekle.java:39)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Java Kodları
package com.ugurkrky.uygulama;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.util.HashMap;
public class ogrenciekle extends AppCompatActivity implements View.OnClickListener{
//Defining views
private EditText editTextName;
private EditText editTextDesg;
private EditText editTextSal;
private Button buttonAdd;
private Button buttonView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Initializing views
editTextName = (EditText) findViewById(R.id.editTextName);
editTextDesg = (EditText) findViewById(R.id.editTextDesg);
editTextSal = (EditText) findViewById(R.id.editTextSalary);
buttonAdd = (Button) findViewById(R.id.buttonAdd);
buttonView = (Button) findViewById(R.id.buttonView);
//Setting listeners to button
buttonAdd.setOnClickListener(this);
buttonView.setOnClickListener(this);
}
//Adding an employee
private void addEmployee(){
final String name = editTextName.getText().toString().trim();
final String desg = editTextDesg.getText().toString().trim();
final String sal = editTextSal.getText().toString().trim();
class AddEmployee extends AsyncTask<Void,Void,String>{
ProgressDialog loading;
@Override
protected void onPreExecute() {
super.onPreExecute();
loading = ProgressDialog.show(ogrenciekle.this,"Adding...","Wait...",false,false);
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
loading.dismiss();
Toast.makeText(ogrenciekle.this,s,Toast.LENGTH_LONG).show();
}
@Override
protected String doInBackground(Void... v) {
HashMap<String,String> params = new HashMap<>();
params.put(Config.KEY_EMP_NAME,name);
params.put(Config.KEY_EMP_DESG,desg);
params.put(Config.KEY_EMP_SAL,sal);
RequestHandler rh = new RequestHandler();
String res = rh.sendPostRequest(Config.URL_ADD, params);
return res;
}
}
AddEmployee ae = new AddEmployee();
ae.execute();
}
@Override
public void onClick(View v) {
if(v == buttonAdd){
addEmployee();
}
if(v == buttonView){
startActivity(new Intent(this,ViewAllEmployee.class));
}
}
}