FOROS PROFESIONALES
WINDEV
,
WEBDEV
y
WINDEV Mobile
Inicio
|
Mensajes recientes
|
Conéctese...
|
Desconectar
|
Español
Inicio
→
WINDEV Mobile 2024
→
lancer un backgroundservice en code java
lancer un backgroundservice en code java
Iniciado por Niels, 26,jun. 2017 11:01 - No hay respuesta
Conéctese…
Niels
#1
Publicado el 26,junio 2017 - 11:01
bonjour,
j'essaie de lancer un backgroudservice en code java dans WINDEV Mobile 22.
J'ai essaié tous les choses possible pour le lancer mais il n'y a rien que marche.
Le code marche dans un application android separée.
le code dans windev
android.content.Context activity = getApplicationContext();
activity.startService(new android.content.Intent(activity, be.mydigi.BlueToothService.class));
et le code de OnCreate() pour le service.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
arrayForBlueToothDevice = new ArrayList
();
if (Debug)
Log.e(TAG, "===onCreate==");
final BluetoothManager bluetoothManager =
(BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = bluetoothManager.getAdapter();
// Checks if Bluetooth is supported on the device.
if (mBluetoothAdapter == null) {
Toast.makeText(this, "error_bluetooth_not_supported", Toast.LENGTH_SHORT).show();
}
mBluetoothAdapter.enable();
//To monitor reader connection status
//#1, register card status monitoring
BlueToothReceiver.registerCardStatusMonitoring(mHandler);
//MyBroadcastReceiver
receiver = new BlueToothReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("android.bluetooth.device.action.ACL_CONNECTED");
filter.addAction("android.bluetooth.device.action.ACL_DISCONNECTED");
filter.addAction("android.bluetooth.device.action.FOUND");
filter.addAction("android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED");
//register receiver
registerReceiver(receiver, filter);
try {
OutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/config.txt");
outputStreamWriter = new OutputStreamWriter(out);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
outputStreamWriter.write("hello");
} catch (IOException e) {
e.printStackTrace();
}
final Handler h = new Handler();
final int delay = 180000; //milliseconds
h.postDelayed(new Runnable() {
public void run() {
//do something
serviceStarted = true;
fethianHasEID();
h.postDelayed(this, delay);
}
}, delay);
return super.onStartCommand(intent, flags, startId);
}
Informar
0
0
→ Volver a WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (versiones precedentes)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Búsqueda Tipo
Sólo temas
Todos los mensajes
Periodo Buscar
Cualquier fecha
Última hora
Última 24 horas
Última semana
Último mes
Último año
Cancelar
Vista previa del mensaje
Añadiendo una imagen
Importar una imagen desde una URL
Enviar una imagen desde un archivo de su disco
Arrastrar un archivo o click en "Examinar..."
o
Cancelar
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Texto