Skip to main content
Homepage
Explore
Search or go to…
/
Register
Sign in
Explore
Primary navigation
Project
L
LED_Tisch_App_Android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
LED_Tisch_App_Android
Commits
e1ab840b
Commit
e1ab840b
authored
Nov 28, 2019
by
Jonas Leder
Browse files
Options
Downloads
Patches
Plain Diff
added quick connect (if app run it will try to connect to last used device
parent
d5464dfa
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/de/jonasled/led_table/MainActivity.java
+12
-0
12 additions, 0 deletions
app/src/main/java/de/jonasled/led_table/MainActivity.java
with
12 additions
and
0 deletions
app/src/main/java/de/jonasled/led_table/MainActivity.java
+
12
−
0
View file @
e1ab840b
...
@@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
...
@@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
import
android.bluetooth.BluetoothAdapter
;
import
android.bluetooth.BluetoothAdapter
;
import
android.bluetooth.BluetoothDevice
;
import
android.bluetooth.BluetoothDevice
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView
;
...
@@ -18,11 +19,15 @@ public class MainActivity extends AppCompatActivity {
...
@@ -18,11 +19,15 @@ public class MainActivity extends AppCompatActivity {
private
ListView
lstvw
;
private
ListView
lstvw
;
private
ArrayAdapter
aAdapter
;
private
ArrayAdapter
aAdapter
;
private
BluetoothAdapter
bAdapter
;
private
BluetoothAdapter
bAdapter
;
private
SharedPreferences
preferences
;
private
SharedPreferences
.
Editor
edit
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
setContentView
(
R
.
layout
.
activity_main
);
preferences
=
getSharedPreferences
(
"settings"
,
MODE_PRIVATE
);
edit
=
preferences
.
edit
();
bAdapter
=
BluetoothAdapter
.
getDefaultAdapter
();
bAdapter
=
BluetoothAdapter
.
getDefaultAdapter
();
lstvw
=
(
ListView
)
findViewById
(
R
.
id
.
deviceList
);
lstvw
=
(
ListView
)
findViewById
(
R
.
id
.
deviceList
);
Set
<
BluetoothDevice
>
pairedDevices
=
bAdapter
.
getBondedDevices
();
Set
<
BluetoothDevice
>
pairedDevices
=
bAdapter
.
getBondedDevices
();
...
@@ -40,11 +45,18 @@ public class MainActivity extends AppCompatActivity {
...
@@ -40,11 +45,18 @@ public class MainActivity extends AppCompatActivity {
aAdapter
=
new
ArrayAdapter
(
getApplicationContext
(),
android
.
R
.
layout
.
simple_list_item_1
,
list
);
aAdapter
=
new
ArrayAdapter
(
getApplicationContext
(),
android
.
R
.
layout
.
simple_list_item_1
,
list
);
lstvw
.
setAdapter
(
aAdapter
);
lstvw
.
setAdapter
(
aAdapter
);
}
}
try
{
openControlActivity
(
preferences
.
getString
(
"MAC"
,
""
));
}
catch
(
Exception
e
)
{}
}
}
lstvw
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
(){
lstvw
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
(){
@Override
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
edit
.
putString
(
"MAC"
,
parent
.
getItemAtPosition
(
position
).
toString
().
split
(
"MAC Address: "
)[
1
]);
edit
.
commit
();
openControlActivity
(
parent
.
getItemAtPosition
(
position
).
toString
().
split
(
"MAC Address: "
)[
1
]);
openControlActivity
(
parent
.
getItemAtPosition
(
position
).
toString
().
split
(
"MAC Address: "
)[
1
]);
}
}
});
});
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment