android菜单中没有进程和服务

时间:2015-05-07 13:25:34

标签: android-service

我正在研究android棒棒糖。 我创建了一个活动,用于启动(使用startService(i))服务来扫描BLE。 此应用程序有效。但是android菜单中没有进程和服务(setup => application => running)。为什么?提前致谢



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

        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");
        mWakeLock.acquire();

        Intent i = new Intent(MainActivity.this, IntentServiceExample.class);
        startService(i);
    }






public class IntentServiceExample extends IntentService {
    private final static String TAG = "IntentServiceExample";
    private BluetoothAdapter mBluetoothAdapter;
    private BluetoothLeScanner mBluetoothLeScanner;


    public IntentServiceExample() {
        super(TAG);
    }

    @Override
    protected void onHandleIntent(Intent intent) {

        final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
        mBluetoothAdapter = bluetoothManager.getAdapter();
        mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();

        ScanSettings settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
        mBluetoothLeScanner.startScan(null, settings,mLeScanCallback);
    }

    private final ScanCallback mLeScanCallback = new ScanCallback() {
        public void onScanResult(int callbackType, ScanResult result) {
		CODE		
        }
    };






    <application
        android:allowBackup="true"

        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name="IntentServiceExample"
            android:process=":scan" >
        </service>
    </application>

</manifest>
&#13;
&#13;
&#13;

0 个答案:

没有答案