Új hozzászólás Aktív témák
-
shinodas
tag
Sziasztok srácok!
Van egy látszólag jó példa kódom, aminek elvileg kellene is futni, de minden alkalommal, ha a telefonon kipróbálom FC-t dob. Nem igazán van még tapasztalatom androiddal, ezért kérdezlek titeket, hogy mi lehet a gond? -
shinodas
tag
Helyesbítenék: Debug módban egy ideig fut jól, de ha rendesen elindítom az appot, marad az FC.
A console ezt írja:
[2013-05-05 14:20:32 - Surface2] ------------------------------
[2013-05-05 14:20:32 - Surface2] Android Launch!
[2013-05-05 14:20:32 - Surface2] adb is running normally.
[2013-05-05 14:20:32 - Surface2] Performing com.example.surface2.MainActivity activity launch
[2013-05-05 14:20:32 - Surface2] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2013-05-05 14:20:35 - Surface2] Application already deployed. No need to reinstall.
[2013-05-05 14:20:35 - Surface2] Starting activity com.example.surface2.MainActivity on device skate
[2013-05-05 14:20:36 - Surface2] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.surface2/.MainActivity }
[2013-05-05 14:20:36 - Surface2] ActivityManager: Warning: Activity not started, its current task has been brought to the frontA logCat ezt:
05-05 14:23:52.830: W/ActivityManager(227): Activity destroy timeout for HistoryRecord{409006b8 com.example.surface2/.MainActivity}
05-05 14:23:52.870: D/AndroidRuntime(8898): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
05-05 14:23:52.870: I/AndroidRuntime(8898): Heap size: -Xmx48m
05-05 14:23:52.870: D/AndroidRuntime(8898): CheckJNI is OFF
05-05 14:23:53.130: D/AndroidRuntime(8898): Calling main entry com.android.commands.pm.Pm
05-05 14:23:53.140: D/AndroidRuntime(8898): Shutting down VM
05-05 14:23:53.150: D/dalvikvm(8898): GC_CONCURRENT freed 103K, 70% free 308K/1024K, external 0K/0K, paused 1ms+1ms
05-05 14:23:53.150: I/AndroidRuntime(8898): NOTE: attach of thread 'Binder Thread #3' failed
05-05 14:23:53.150: D/jdwp(8898): adbd disconnected
05-05 14:23:53.150: D/jdwp(8898): Got wake-up signal, bailing out of select
05-05 14:23:53.150: D/dalvikvm(8898): Debugger has detached; object registry had 1 entries
05-05 14:23:53.360: D/AndroidRuntime(8908): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
05-05 14:23:53.360: I/AndroidRuntime(8908): Heap size: -Xmx48m
05-05 14:23:53.360: D/AndroidRuntime(8908): CheckJNI is OFF
05-05 14:23:53.620: D/AndroidRuntime(8908): Calling main entry com.android.commands.am.Am
05-05 14:23:53.630: I/ActivityManager(227): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.surface2/.MainActivity } from pid 8908
05-05 14:23:53.670: D/AndroidRuntime(8908): Shutting down VM
05-05 14:23:53.690: I/AndroidRuntime(8908): NOTE: attach of thread 'Binder Thread #3' failed
05-05 14:23:53.690: D/dalvikvm(8908): GC_CONCURRENT freed 103K, 69% free 325K/1024K, external 0K/0K, paused 0ms+1ms
05-05 14:23:53.700: D/jdwp(8908): adbd disconnected
05-05 14:23:53.700: D/jdwp(8908): Got wake-up signal, bailing out of select
05-05 14:23:53.700: D/dalvikvm(8908): Debugger has detached; object registry had 1 entries
05-05 14:23:53.700: W/WindowManager(227): Rebuild removed 5 windows but added 3
05-05 14:23:53.780: D/dalvikvm(7054): GC_EXPLICIT freed 21K, 50% free 2701K/5379K, external 0K/0K, paused 432ms
05-05 14:23:58.320: I/Process(8882): Sending signal. PID: 8882 SIG: 9
05-05 14:23:58.330: E/InputDispatcher(227): channel '40a14228 com.example.surface2/com.example.surface2.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8
05-05 14:23:58.330: E/InputDispatcher(227): channel '40a14228 com.example.surface2/com.example.surface2.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
05-05 14:23:58.330: I/ActivityManager(227): Process com.example.surface2 (pid 8882) has died.
05-05 14:23:58.350: I/WindowManager(227): WIN DEATH: Window{40a14228 com.example.surface2/com.example.surface2.MainActivity paused=false}
05-05 14:23:58.350: I/WindowManager(227): WIN DEATH: Window{4099a168 SurfaceView paused=false}
05-05 14:23:58.390: W/InputManagerService(227): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@405ab318 -
shinodas
tag
Illetve azt megtudnátok mondani, hogy Surfaceview-ra hogyan lehet egy textViewt aplákálni?
-
shinodas
tag
Multi touch-al próbálkozok, és az lenne a kérdésem, hogyan tudnám egyszerre mozgatni a két kört? Mert csak az egyik elem követi az ujjam, a másik pedig a mozgatott objektumot követi, ha a másik ujjammal is megérintem a képernyőt.
[ Szerkesztve ]
-
shinodas
tag
válasz shinodas #648 üzenetére
Az általad mutatott példában, mikor van a ciklus, ott hogyan tudom elkülöníteni a két pointerem értékét?
case MotionEvent.ACTION_MOVE:
pointerCount = event.getPointerCount();
for(cnt = 0; cnt<pointerCount && cnt<MAX_POINTER;cnt++)
{
posx[cnt] = event.getX(cnt);
posy[cnt] = event.getY(cnt);
id[cnt] = event.getPointerId(cnt);
mPosX = posx[cnt];
mPosY = posy[cnt];
}
this.invalidate();
break;Itt szeretnék mPosX2, és mPosY2-nek is értéket adni, de nem tudom, azt a pointert, hogyan kezeljem le.
[ Szerkesztve ]
-
shinodas
tag
Sziasztok!
Kiszeretném írni egy egyszerű stringbe a bluetooth státuszát. Hova kellene tennem, vagy meghívnom ezt a függvényt, hogy folyamatosan fusson le, és változásnál az oda tartozó stringet írja ki? Ugyanis csak a program indításnál fut le így.
public void BT_stat_Check(){
TextView t = new TextView(this);
t = (TextView)findViewById(R.id.BtStat);
if(bluetooth.isEnabled()){
//kiírom a bluetooth adatait
String mydeviceaddress = bluetooth.getAddress();
String mydevicename = bluetooth.getName();
status = mydevicename + " : " + mydeviceaddress;
t.setText(status); // kirakom a képernyőre a státuszt
}
else{
status = "Bluetooth is disabled.";
t.setText(status);
}
} -
shinodas
tag
Illetve még amit akartam, hogy erre:
public class Discover {
IntentFilter discoveryFilter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
registerReceiver(_dicoveryReceiver, discoveryFilter);
IntentFilter foundFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(_foundReceiver, foundFilter);...
}
mi a csudáért húzza alá nekem a registerReceiver(_dicoveryReceiver, discoveryFilter); és registerReceiver(_foundReceiver, foundFilter); sorokat? A _dicoveryReceiver, és a _foundReceiver fgv-nyek meg vannak alattuk írva pedig.
-
shinodas
tag
package com.example.tuts;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
public class DiscoveryActivity {
IntentFilter discoveryFilter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
registerReceiver(_dicoveryReceiver, discoveryFilter);
IntentFilter foundFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(_foundReceiver, foundFilter);
private BroadcastReceiver _foundReceiver = new BroadcastReceiver(){
public void onReceive(Context context, Intent intent){
//keresés eredménye
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
//eredmény listába tétele
_device.add(device);
//lista megjelenítése
showDevices();
}
};
private BroadcastReceiver _dicoveryReceiver = new BroadcastReceiver(){
public void onReceive(Context context, Intent intent){
unregisterReceiver(_foundReceiver);
unregisterReceiver(this);
_discoveryFinished = true;
}
};
}Egy tutorial szerint haladok ezzel, azt írja, kéne neki működnie
[ Szerkesztve ]
-
shinodas
tag
Srácok,
Ubuntu 12.04 alatt próbálok egy androidos környezetet kialakítani. De ebbe a hibába ütközök: [kép]
Pedig a /etc/udev/rules.d/ -ban létrehoztam a szükséges fájlt is. Tapasztalatok? -
shinodas
tag
Nem akar nekem ez az androidozás linux alatt beindulni. thon73 leírása alapján rendesen sikerült feltelepíteni, és konfigolni mindent. Viszont most meg az eclipse rakoncátlankodik, "could not find xyz.apk" hibaüzenetet dob, ha a telefonon akarnám a projectet debuggolni. Már a net alapján feltúrtam a beállításokat, de csak ezt dobja...találkoztatok már ilyesmivel?
-
shinodas
tag
apt-get install ia32-libs így kompletten ment újra. Igen ez 64bites Ubuntu 12.04, a probléma az volt, hogy valamiért az eclipse nem akarta használni ezeket a libeket, amiért nem generált apk-t (gondolom én ) SZóval miután a fentebb kapott linken lévő leírás alapján az adb patenttül működött, a 32 bites libek után meg az eclipse is dolgozott már rendesen.
java-ból pedig openjdk 7.
[ Szerkesztve ]
-
shinodas
tag
Van egy ilyen kódom:
package com.example.bluetooth_linugz;
import java.util.Iterator;
import java.util.Set;
import java.util.UUID;
import android.os.Bundle;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends Activity {
Set<BluetoothDevice> pairedDevices;
BluetoothAdapter btInterface;
BluetoothSocket socket;
String ROBOTNAME = "peter-VPCEH1M1E-0";
UUID MY_UUID;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void findRobot (View v){
try{
btInterface = BluetoothAdapter.getDefaultAdapter();
pairedDevices = btInterface.getBondedDevices();
Iterator<BluetoothDevice> it = pairedDevices.iterator();
while(it.hasNext()){
BluetoothDevice bd = it.next();
if(bd.getName().equalsIgnoreCase(ROBOTNAME)){ //ha a listában van a megadott eszköz, akkor csatlakozni próbál
MY_UUID = bd.getUuids()[0].getUuid();
connectToRobot(bd);
return;
}
}
}catch(Exception e){
String tag = "Első";
Log.e(tag, "Failed in findRobot() " + e.getMessage());
}
}
private void connectToRobot(BluetoothDevice bd) {
try{
//socket = bd.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
socket = bd.createRfcommSocketToServiceRecord(MY_UUID);
socket.connect();
}catch(Exception e){
String tag = "Második";
Log.e(tag, "Error interacing with remote device [" + e.getMessage() + "]");
}
}
}Egy ubuntut futtató laptophoz szeretnék még csak simán csatlakozni, viszont a csatlakozásnál "Connection reset by peer" üzenetet kapok logcatban. Mi lehet a gond?
[ Szerkesztve ]
-
shinodas
tag
Sziasztok Srácok!
Még mindig Bluetoothal szenvedek. Van egy activity, amiben a párosított eszközöket listázom ki. Azt szeretném elérni, hogy ha kiválasztok egy eszközt, ahhoz csatlakozzon. A csatlakozás részt egy másik activity tartalmazza. Gondolom, hogy a kiválasztott lista elemet kellene átadni a másik activitynek, hogy ahhoz csatlakozzon. Egyáltalán jó a csatlakozós activitym?
Remélem valaki tud segíteni -
shinodas
tag
Köszi!
Viszont van egy ilyenem:
listview.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> av, View v,
int arg2, long arg3) {
bluetooth.cancelDiscovery();
String info = ((TextView) v).getText().toString();
String address = info.substring(info.length()-17);
Intent intent = new Intent();
intent.putExtra("EXTRA_DEVICE_ADDRESS", address);
setResult(Activity.RESULT_OK, intent);
finish();
}
});C][/M]
És itt nem igazán tiszta, hogyan kellene a másik activityrre hivatkoznom. Mert most ezzel azt csinálja, hogy a lista egy elemét kiválasztva kilép az appból. -
shinodas
tag
Köszi a válaszokat! Azt hiszem megoldottam, már csak egy apróság (ELnézést a tényleg primitív kérdéseimért, de tényleg abszolút kezdő vagyok)
Szóval a logcat azt mondja, h kapcsolódni próbál az eszköz de nem tudja azt befejezni, először azt írja, hogy kapcsolódva, majd 2 sorral lejjebb már ugyan ez az állapot false.import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.os.Handler;
import android.util.Log;
public class BluetoothConnection extends Thread {
private BluetoothAdapter bluetooth = null;
private BluetoothSocket socket = null;
private InputStream inputStream = null;
private OutputStream outputStream = null;
private static final UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
static final int BL_NOT_AVAILABLE = 1;
static final int BL_SOCKET_FAILED = 2;
protected static final int BL_INCORRECT_ADDRESS = 3;
private Handler mHandler = null;
public BluetoothConnection(Context context, Handler handler){
bluetooth = BluetoothAdapter.getDefaultAdapter();
mHandler = handler;
if(bluetooth == null){
mHandler.sendEmptyMessage(BL_NOT_AVAILABLE);
return;
}
}
public void BT_Connect(String Address){
Log.d("CONNECTION", "...On Resume...");
String address = Address;
if(!BluetoothAdapter.checkBluetoothAddress(address)){
return;
}else{
BluetoothDevice device = bluetooth.getRemoteDevice(address);
try{
socket = device.createRfcommSocketToServiceRecord(uuid);
}catch(IOException e){
Log.d("RFCOMM", "socket create fail" + e.getMessage());
mHandler.sendEmptyMessage(BL_SOCKET_FAILED);
return;
}
bluetooth.cancelDiscovery();
[B]Log.d("BLUETOOTH", "-----CONNECTING---"); //idáig jut[/B]
try{
socket.connect();
Log.d("BLUETOOTH", "Connecting is ok");
}catch(IOException e){
try{
socket.close();
}catch(IOException e2){
Log.d("BLUETOOTH", "In onResume() and unable to close socket during connection failure" + e2.getMessage());
mHandler.sendEmptyMessage(BL_SOCKET_FAILED);
return;
}
}
}
}
}LOGCAT:
06-07 12:48:35.200: I/ActivityManager(231): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.hxxpd/.MainActivity } from pid 11341
06-07 12:48:35.270: D/CONNECTION(11934): ...On Resume...
06-07 12:48:35.280: E/BluetoothService.cpp(231): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session)
06-07 12:48:35.280: D/BLUETOOTH(11934): -----CONNECTING---
06-07 12:48:35.740: E/BluetoothEventLoop.cpp(231): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/10666/hci0/dev_CC_AF_78_B4_F7_6A
06-07 12:48:35.740: D/BluetoothService(231): setRemoteDeviceProperty addr = CC:AF:78:B4:F7:6A name = Connected value = true
06-07 12:48:37.090: D/BluetoothService(231): updateDeviceServiceChannelCache(CC:AF:78:B4:F7:6A)
06-07 12:48:37.110: D/BluetoothService(231): uuid(system): 0000111e-0000-1000-8000-00805f9b34fb 3
06-07 12:48:37.120: D/BluetoothService(231): uuid(system): 00001105-0000-1000-8000-00805f9b34fb 10
06-07 12:48:37.140: V/BluetoothEventRedirector(11975): Received android.bleutooth.device.action.UUID
06-07 12:48:37.140: D/BluetoothService(231): Cleaning up failed UUID channel lookup: CC:AF:78:B4:F7:6A 00001101-0000-1000-8000-00805f9b34fb
06-07 12:48:37.330: E/CachedBluetoothDevice(11975): updating profiles for JABBA
06-07 12:48:37.330: V/CachedBluetoothDevice(11975): Class: 7e010c
06-07 12:48:37.330: V/CachedBluetoothDevice(11975): UUID:
06-07 12:48:37.360: V/CachedBluetoothDevice(11975): 00001000-0000-1000-8000-00805f9b34fb
06-07 12:48:37.390: V/CachedBluetoothDevice(11975): 00001104-0000-1000-8000-00805f9b34fb
06-07 12:48:37.390: V/CachedBluetoothDevice(11975): 00001105-0000-1000-8000-00805f9b34fb
06-07 12:48:37.390: V/CachedBluetoothDevice(11975): 00001106-0000-1000-8000-00805f9b34fb
06-07 12:48:37.410: V/CachedBluetoothDevice(11975): 0000110a-0000-1000-8000-00805f9b34fb
06-07 12:48:37.420: V/CachedBluetoothDevice(11975): 0000110b-0000-1000-8000-00805f9b34fb
06-07 12:48:37.420: V/CachedBluetoothDevice(11975): 0000110c-0000-1000-8000-00805f9b34fb
06-07 12:48:37.420: V/CachedBluetoothDevice(11975): 0000110e-0000-1000-8000-00805f9b34fb
06-07 12:48:37.420: V/CachedBluetoothDevice(11975): 00001112-0000-1000-8000-00805f9b34fb
06-07 12:48:37.440: V/CachedBluetoothDevice(11975): 00001115-0000-1000-8000-00805f9b34fb
06-07 12:48:37.440: V/CachedBluetoothDevice(11975): 0000111b-0000-1000-8000-00805f9b34fb
06-07 12:48:37.470: V/CachedBluetoothDevice(11975): 0000111e-0000-1000-8000-00805f9b34fb
06-07 12:48:37.470: V/CachedBluetoothDevice(11975): 0000111f-0000-1000-8000-00805f9b34fb
06-07 12:48:37.470: V/CachedBluetoothDevice(11975): 00001123-0000-1000-8000-00805f9b34fb
06-07 12:48:37.470: V/CachedBluetoothDevice(11975): 0350278f-3dca-4e62-831d-a41165ff906c
06-07 12:48:37.470: E/CachedBluetoothDevice(11975): onUuidChanged: Time since last connect67267896
06-07 12:48:41.100: E/BluetoothEventLoop.cpp(231): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/10666/hci0/dev_CC_AF_78_B4_F7_6A
06-07 12:48:41.100: D/BluetoothService(231): setRemoteDeviceProperty addr = CC:AF:78:B4:F7:6A name = Connected value = false
06-07 12:48:41.330: V/BluetoothEventRedirector(11975): Received android.bleutooth.device.action.UUID
06-07 12:48:41.350: E/CachedBluetoothDevice(11975): updating profiles for JABBA
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): Class: 7e010c
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): UUID:
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001000-0000-1000-8000-00805f9b34fb
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001104-0000-1000-8000-00805f9b34fb
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001105-0000-1000-8000-00805f9b34fb
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001106-0000-1000-8000-00805f9b34fb
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 0000110a-0000-1000-8000-00805f9b34fb
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 0000110b-0000-1000-8000-00805f9b34fb
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 0000110c-0000-1000-8000-00805f9b34fb
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 0000110e-0000-1000-8000-00805f9b34fb
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001112-0000-1000-8000-00805f9b34fb
06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001115-0000-1000-8000-00805f9b34fb
06-07 12:48:41.359: V/CachedBluetoothDevice(11975): 0000111b-0000-1000-8000-00805f9b34fb
06-07 12:48:41.359: V/CachedBluetoothDevice(11975): 0000111e-0000-1000-8000-00805f9b34fb
06-07 12:48:41.359: V/CachedBluetoothDevice(11975): 0000111f-0000-1000-8000-00805f9b34fb
06-07 12:48:41.359: V/CachedBluetoothDevice(11975): 00001123-0000-1000-8000-00805f9b34fb
06-07 12:48:41.359: V/CachedBluetoothDevice(11975): 0350278f-3dca-4e62-831d-a41165ff906c
06-07 12:48:41.359: E/CachedBluetoothDevice(11975): onUuidChanged: Time since last connect67271789[ Szerkesztve ]
-
shinodas
tag
Végre sikerült a bluetooth témát megoldani. Tudok küldeni normálisan adatot.
Egy olyan kérdésem lenne, hogy most teszt jelleggel van az, hogy ha megnyomok egy gombot, akkor kiküld egy byte tömbböt. Ez szépen működik is. De valamiért, ha meghívok egy másik activityt, akkor az a másik activity nem indul el, FC-vel kilép. Addig kilogikáztam, hogy a handler a ludas, viszont tapasztalatlanságom miatt nem tudom mi nem tetszik neki.Lényeg a lényeg a BluetoothConnection.write függvényt szeretném mind a 2 activityből elérni akár.
Ide szeretném bepaszírozni a BluetoothConnection.write függvényemet