File tree Expand file tree Collapse file tree 9 files changed +28
-28
lines changed
java/com/sample/android/bluetoothle
identity/credentialmanager/src/main
misc/src/androidTest/java/com/example/snippets Expand file tree Collapse file tree 9 files changed +28
-28
lines changed Original file line number Diff line number Diff line change 37
37
with :
38
38
distribution : ' zulu'
39
39
java-version : ' 17'
40
- - name : Build Compose
41
- run : ./gradlew :compose:snippets:build
42
- - name : Build recompose snippets
43
- run : ./gradlew :compose:recomposehighlighter:build
44
- - name : Build kotlin snippets
45
- run : ./gradlew :kotlin:build
46
- - name : Build Wear snippets
47
- run : ./gradlew :wear:build
48
- - name : Build misc snippets
49
- run : ./gradlew :misc:build
50
- - name : Build XR snippets
51
- run : ./gradlew :xr:build
40
+ - name : Build All
41
+ run : ./gradlew build --stacktrace
52
42
- name : Build Watch Face Push validation snippets
53
- run : ./gradlew :watchfacepush:validator:run
43
+ run : ./gradlew :watchfacepush:validator:run --stacktrace
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
- <manifest xmlns : android =" http://schemas.android.com/apk/res/android"
3
- package =" com.sample.android.bluetoothle" >
2
+ <manifest xmlns : android =" http://schemas.android.com/apk/res/android" >
4
3
5
4
<uses-permission android : name =" android.permission.BLUETOOTH_CONNECT" />
6
5
<uses-permission android : name =" android.permission.BLUETOOTH_SCAN" />
23
22
<uses-permission android : name =" android.permission.BLUETOOTH" />
24
23
<uses-permission android : name =" android.permission.BLUETOOTH_ADMIN" />
25
24
25
+ <uses-permission android : name =" android.permission.ACCESS_COARSE_LOCATION" />
26
26
<uses-permission android : name =" android.permission.ACCESS_FINE_LOCATION" />
27
-
28
27
</manifest >
Original file line number Diff line number Diff line change 1
1
package com .sample .android .bluetoothle .java ;
2
2
3
- import androidx .appcompat .app .AppCompatActivity ;
4
-
3
+ import android .Manifest ;
5
4
import android .bluetooth .BluetoothAdapter ;
6
5
import android .bluetooth .BluetoothManager ;
7
6
import android .content .Context ;
8
7
import android .content .Intent ;
9
8
import android .os .Bundle ;
10
9
10
+ import androidx .annotation .RequiresPermission ;
11
+ import androidx .appcompat .app .AppCompatActivity ;
12
+
11
13
import com .sample .android .bluetoothle .R ;
12
14
13
15
public class MainActivity extends AppCompatActivity {
@@ -19,6 +21,7 @@ protected void onCreate(Bundle savedInstanceState) {
19
21
setContentView (R .layout .activity_main );
20
22
}
21
23
24
+ @ RequiresPermission (Manifest .permission .BLUETOOTH_CONNECT )
22
25
private void setUpBLE () {
23
26
// [START get_bluetooth_adapter]
24
27
// Initializes Bluetooth adapter.
Original file line number Diff line number Diff line change 16
16
17
17
package com.sample.android.bluetoothle.kotlin
18
18
19
+ import android.Manifest
19
20
import android.app.ListActivity
20
21
import android.bluetooth.BluetoothAdapter
21
22
import android.bluetooth.le.ScanCallback
22
23
import android.bluetooth.le.ScanResult
23
24
import android.os.Handler
25
+ import androidx.annotation.RequiresPermission
24
26
import com.sample.android.bluetoothle.java.LeDeviceListAdapter
25
27
26
28
/* *
@@ -47,6 +49,7 @@ class DeviceScanActivity : ListActivity() {
47
49
// Stops scanning after 10 seconds.
48
50
private val SCAN_PERIOD : Long = 10000
49
51
52
+ @RequiresPermission(Manifest .permission.BLUETOOTH_SCAN )
50
53
private fun scanLeDevice () {
51
54
if (! mScanning) { // Stops scanning after a pre-defined scan period.
52
55
handler.postDelayed({
Original file line number Diff line number Diff line change 16
16
17
17
package com.sample.android.bluetoothle.kotlin
18
18
19
+ import android.Manifest
19
20
import android.bluetooth.BluetoothAdapter
20
21
import android.bluetooth.BluetoothManager
21
22
import android.content.Context
22
23
import android.content.Intent
23
24
import android.os.Bundle
25
+ import androidx.annotation.RequiresPermission
24
26
import androidx.appcompat.app.AppCompatActivity
25
27
26
28
class MainActivity : AppCompatActivity () {
@@ -31,6 +33,7 @@ class MainActivity : AppCompatActivity() {
31
33
super .onCreate(savedInstanceState)
32
34
}
33
35
36
+ @RequiresPermission(Manifest .permission.BLUETOOTH_CONNECT )
34
37
private fun setUpBLE () {
35
38
// [START get_bluetooth_adapter]
36
39
// Initializes Bluetooth adapter.
Original file line number Diff line number Diff line change 45
45
android : enabled =" true"
46
46
android : exported =" true"
47
47
android : label =" My Credential Provider"
48
- android : icon =" <any drawable icon> "
48
+ android : icon =" @mipmap/ic_launcher "
49
49
android : permission =" android.permission.BIND_CREDENTIAL_PROVIDER_SERVICE"
50
50
tools : targetApi =" upside_down_cake" >
51
51
<intent-filter >
Original file line number Diff line number Diff line change 16
16
17
17
package com .example .snippets ;
18
18
19
+ import androidx .appcompat .app .AppCompatActivity ;
19
20
import androidx .test .core .app .ActivityScenario ;
20
21
import androidx .test .ext .junit .rules .ActivityScenarioRule ;
21
22
import org .junit .Rule ;
@@ -33,16 +34,18 @@ public void activity_launched_notLetterBoxed() {
33
34
try (ActivityScenario <MainActivity > scenario =
34
35
ActivityScenario .launch (MainActivity .class )) {
35
36
scenario .onActivity ( activity -> {
36
- assertFalse (isLetterboxed (activity ));
37
+ assertFalse (activity . isLetterboxed ());
37
38
});
38
39
}
39
40
}
40
41
// [END android_device_compatibility_mode_assert_isLetterboxed_java]
41
42
42
43
43
- // Method used by snippets.
44
- public boolean isLetterboxed (MainActivity activity ) {
45
- return true ;
46
- }
44
+ // Class used by snippets.
47
45
46
+ class MainActivity extends AppCompatActivity {
47
+ public boolean isLetterboxed () {
48
+ return true ;
49
+ }
50
+ }
48
51
}
Original file line number Diff line number Diff line change @@ -36,10 +36,9 @@ class DeviceCompatibilityModeTestKotlinSnippets {
36
36
}
37
37
// [END android_device_compatibility_mode_assert_isLetterboxed_kotlin]
38
38
39
- // Classes used by snippets.
39
+ // Class used by snippets.
40
40
41
41
class MainActivity : AppCompatActivity () {
42
-
43
42
fun isLetterboxed (): Boolean {
44
43
return true
45
44
}
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ android {
19
19
sourceCompatibility = JavaVersion .VERSION_11
20
20
targetCompatibility = JavaVersion .VERSION_11
21
21
}
22
- kotlinOptions {
23
- jvmTarget = " 11 "
22
+ kotlin {
23
+ jvmToolchain( 11 )
24
24
}
25
25
buildFeatures {
26
26
compose = true
You can’t perform that action at this time.
0 commit comments