Java Code Examples for no.nordicsemi.android.log.Logger#openSession()

The following examples show how to use no.nordicsemi.android.log.Logger#openSession() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BleProfileService.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    if (intent == null || !intent.hasExtra(EXTRA_DEVICE_ADDRESS))
        throw new UnsupportedOperationException("No device address at EXTRA_DEVICE_ADDRESS key");

    final Uri logUri = intent.getParcelableExtra(EXTRA_LOG_URI);
    logSession = Logger.openSession(getApplicationContext(), logUri);
    deviceName = intent.getStringExtra(EXTRA_DEVICE_NAME);

    Logger.i(logSession, "Service started");

    final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    final String deviceAddress = intent.getStringExtra(EXTRA_DEVICE_ADDRESS);
    bluetoothDevice = adapter.getRemoteDevice(deviceAddress);

    bleManager.setLogger(logSession);
    onServiceStarted();
    bleManager.connect(bluetoothDevice)
            .useAutoConnect(shouldAutoConnect())
            .retry(3, 100)
            .enqueue();
    return START_REDELIVER_INTENT;
}
 
Example 2
Source File: BleProfileServiceReadyActivity.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected final void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	ensureBLESupported();
	if (!isBLEEnabled()) {
		showBLEDialog();
	}

	// Restore the old log session
	if (savedInstanceState != null) {
		final Uri logUri = savedInstanceState.getParcelable(LOG_URI);
		logSession = Logger.openSession(getApplicationContext(), logUri);
	}

	// In onInitialize method a final class may register local broadcast receivers that will listen for events from the service
	onInitialize(savedInstanceState);
	// The onCreateView class should... create the view
	onCreateView(savedInstanceState);

	final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
	setSupportActionBar(toolbar);

	// Common nRF Toolbox view references are obtained here
	setUpView();
	// View is ready to be used
	onViewCreated(savedInstanceState);

	LocalBroadcastManager.getInstance(this).registerReceiver(commonBroadcastReceiver, makeIntentFilter());
}
 
Example 3
Source File: MainFragment.java    From nRF-Logger-API with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	if (savedInstanceState != null) {
		Uri uri = savedInstanceState.getParcelable(SIS_SESSION_URL);
		mLogSession = Logger.openSession(requireContext(), uri);
		mSelectedLevel = savedInstanceState.getInt(SIS_SELECTED_LEVEL);
	}
}
 
Example 4
Source File: nRFLoggerTree.java    From nRF-Logger-API with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public nRFLoggerTree(final @NonNull Context context, final @Nullable Uri uri) {
	this.session = Logger.openSession(context, uri);
}