Kişisel Sayfaları
İlgi Alanları
İş Tecrubesi
Eğitim Geçmişi
Sertifikalar & Başarılar
Kullanıcıya ait test sonucu bulunmamaktadır.
Dil Becerileri
Son Forum Aktiviteleri
4gps ile yakınlık derecesine göre sıralama
Merhaba arkadaşlar yaptığım uygulamada veritabanımda kayıtlı yerlerin enlem boylam bilgilerini tutuyorum. Uygulama çalıştığında gps den telefonun bulunduğu lokasyonun enlem ve boylamını alıp veritabanındaki yerlerin enlem boylam farkına göre telfona olan uzaklıklarını hesaplayıp daha sonra da bunları customlistview de en yakından uzağa göre sıralamak istiyorum fakat nasıl yapacağımı bilmiyorum. Bilen birileri varsa yardımlarını bekiyorum.kolay gelsin.
Maalesef uygulama durdu
Merhaba telefonda uygulamayı çalıştırdım butona bastıgım zaman maalesef uygulama durdu hatası verip kapaniyor.
Neden böyle yapıyor. Logcat aşagıdadır.
08-01 21:30:22.177 27532-27532/? D/dalvikvm﹕ Late-enabling CheckJNI
08-01 21:30:22.387 27532-27532/com.example.emrisb.ledcontrol_withbt E/Trace﹕ error opening trace file: No such file or directory (2)
08-01 21:30:22.937 27532-27532/com.example.emrisb.ledcontrol_withbt D/HardwareRenderer﹕ Profiling hardware renderer
08-01 21:30:23.198 27532-27532/com.example.emrisb.ledcontrol_withbt D/libEGL﹕ loaded /system/lib/egl/libEGL_mali.so
08-01 21:30:23.228 27532-27532/com.example.emrisb.ledcontrol_withbt D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_mali.so
08-01 21:30:23.228 27532-27532/com.example.emrisb.ledcontrol_withbt D/libEGL﹕ loaded /system/lib/egl/libGLESv2_mali.so
08-01 21:30:23.278 27532-27532/com.example.emrisb.ledcontrol_withbt D/OpenGLRenderer﹕ Enabling debug mode 0
08-01 21:30:28.453 27532-27532/com.example.emrisb.ledcontrol_withbt D/AndroidRuntime﹕ Shutting down VM
08-01 21:30:28.453 27532-27532/com.example.emrisb.ledcontrol_withbt W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41dc2318)
08-01 21:30:28.603 27532-27532/com.example.emrisb.ledcontrol_withbt E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at com.example.emrisb.ledcontrol_withbt.MainActivity.ledON(MainActivity.java:203)
at com.example.emrisb.ledcontrol_withbt.MainActivity$3.onClick(MainActivity.java:136)
at android.view.View.performClick(View.java:4103)
at android.view.View$PerformClick.run(View.java:17117)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4744)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
08-01 21:30:33.918 27532-27532/com.example.emrisb.ledcontrol_withbt I/Process﹕ Sending signal. PID: 27532 SIG: 9
bu hatanın nedenini bilen acil
Merhaba arkadaşlar,
Android Studio da yaptığım uygulamayı telefonumda run ederken telefonumda aşağıdaki hata geliyor. Nedenini bilen acil cevap verebilirse sevinirim.
application app name is waiting for the debugger to attach on android studio
Kolay gelsin.
Maalesef uygulama durdu
package com.example.emrisb.ledcontrol_withbt;
import android.app.Activity;
import android.content.IntentFilter;
import android.os.Bundle;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.UUID;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements OnItemClickListener {
public static final UUID myUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
public static final int baglanti = 0;
public static final int smsOku = 1;
OutputStream outputStream;
InputStream inputStream;
ArrayAdapter<String> adapterList;
BluetoothAdapter btAdapter;
ArrayList<String> eslesen;
ArrayList<BluetoothDevice> aygitlar;
IntentFilter filter;
BroadcastReceiver receiver;
Set<BluetoothDevice> deviceArray;
private Button btn_on, btn_off;
private TextView txt_durum;
private ListView liste;
public Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case baglanti:
ConnectedThread connectedThread = new ConnectedThread((BluetoothSocket) msg.obj);
txt_durum.setText("Baglandi.");
break;
case smsOku:
byte[] bufOku = (byte[]) msg.obj;
String str = new String(bufOku);
Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT).show();
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt_durum = (TextView) findViewById(R.id.tDurum);
liste = (ListView) findViewById(R.id.liste);
liste.setOnItemClickListener(this);
adapterList = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, 0);
liste.setAdapter(adapterList);
btAdapter = BluetoothAdapter.getDefaultAdapter();
eslesen = new ArrayList<String>();
filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
aygitlar = new ArrayList<BluetoothDevice>();
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice aygit = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
aygitlar.add(aygit);
String s ="";
for (int i = 0; i < eslesen.size(); i++) {
if (aygit.getName().equals(eslesen.get(i))) {
s = "(eslesti)";
}
}
adapterList.add(aygit.getName() + "" + s + "\n" + aygit.getAddress());
} else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
if (btAdapter.getState() == btAdapter.STATE_OFF) {
btAdapter_Ac();
}
}
}
};
registerReceiver(receiver, filter);
filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
registerReceiver(receiver, filter);
if (btAdapter == null) {
txt_durum.setText("Bluetooth yok.");
Toast.makeText(getApplicationContext(), "Cihaziniza bluetooth yok", Toast.LENGTH_LONG).show();
} else {
if (btAdapter.isEnabled()) {
btAdapter_Ac();
}
secim();
startDiscovery();
btn_on = (Button) findViewById(R.id.btn_on);
btn_on.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
ledON();
} catch (IOException e) {
}
}
});
btn_off = (Button) findViewById(R.id.btn_off);
btn_off.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
ledOFF();
} catch (IOException e) {
}
}
});
}
}
private void btAdapter_Ac() {
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(intent, 1);
}
private void secim() {
deviceArray = btAdapter.getBondedDevices();
if (deviceArray.size() > 0) {
for (BluetoothDevice aygit : deviceArray) {
eslesen.add(aygit.getName());
}
}
}
private void startDiscovery() {
btAdapter.cancelDiscovery();
btAdapter.startDiscovery();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//BT aygitini secme islemi burada yapilir.
if (btAdapter.isDiscovering()) {
btAdapter.cancelDiscovery();
}
if (adapterList.getItem(position).contains("(eslesti)")) {
BluetoothDevice secilen_aygit = aygitlar.get(position);
ConnectThread connect = new ConnectThread(secilen_aygit);
connect.start();
txt_durum.setText("Baglandi!");
} else {
Toast.makeText(getApplicationContext(), "Bluetooth aygitina baglanilamadi", Toast.LENGTH_SHORT).show();
txt_durum.setText("Baglanamadi!");
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_CANCELED) {
Toast.makeText(getApplicationContext(), "Bluetooth aygitinizi acmaniz gerekmektedir.", Toast.LENGTH_SHORT).show();
finish();
}
}
public void ledON() throws IOException {
outputStream.write("1" .getBytes());
}
public void ledOFF() throws IOException {
outputStream.write("2" .getBytes());
}
private class ConnectThread extends Thread {
private final BluetoothSocket btSocket;
private final BluetoothDevice btDevice;
public ConnectThread(BluetoothDevice aygit) {
BluetoothSocket tmp = null;
btDevice = aygit;
try {
tmp = aygit.createRfcommSocketToServiceRecord(myUuid);
} catch (IOException e) {
txt_durum.setText("Baglanti yok");
}
btSocket = tmp;
}
@Override
public void run() {
btAdapter.cancelDiscovery();
try {
btSocket.connect();
} catch (IOException e) {
try {
btSocket.close();
} catch (IOException e1) {
}
return;
}
mHandler.obtainMessage(baglanti, btSocket).sendToTarget();
}
public void cancel() {
try {
btSocket.close();
} catch (IOException e) {
}
}
}
private class ConnectedThread extends Thread {
private final BluetoothSocket btSocket1;
public ConnectedThread(BluetoothSocket socket) {
btSocket1 = socket;
InputStream tmpIN = null;
OutputStream tmpOUT = null;
try {
tmpIN = socket.getInputStream();
tmpOUT = socket.getOutputStream();
} catch (IOException e) {
}
inputStream = tmpIN;
outputStream = tmpOUT;
}
public void run() {
byte[] buffer;
int bytes;
while (true) {
try {
buffer = new byte[1024];
bytes = inputStream.read(buffer);
} catch (IOException e) {
break;
}
}
}
public void cancel() {
try {
btSocket1.close();
} catch (IOException e) {
}
}
}
}