API 19 and Bluetooth Low Energy - Android Software/Hacking General [Developers Only]

I am currently working on a project to connect a Google Glass Explorer Edition (Android Kitkat and therefore API 19) to an Arduino board emitting data in BLE.
I have checked that this is possible and I have found and installed an APK that manages to make the link. However, I want to make a slightly different application.
The application I want to make has a splash screen and a main activity displaying the different values on TextView. This part is already working.
Splash Screen:
Java:
package com.example.flyin_glass;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
/* loaded from: classes.dex */
public class SplashScreenActivity extends AppCompatActivity {
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, android.app.Activity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
Runnable runnable = new Runnable() { // from class: com.example.myapplication.SplashScreenActivity.1
@Override // java.lang.Runnable
public void run()
{
Intent intent = new Intent(SplashScreenActivity.this.getApplicationContext(), MainActivity.class);
SplashScreenActivity.this.startActivity(intent);
SplashScreenActivity.this.finish();
}
};
new Handler().postDelayed(runnable, 3000L);
}
}
Main activity :
Java:
package com.example.flyin_glass;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.Manifest;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.*;
import android.bluetooth.le.*;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.content.Context;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
My goal would be to code (in main activity) the management of the BLE, i.e. the automatic connection to my Arduino (which has a specific UUID) as well as the data retrieval and display in TextView.
Being a novice in Android development, the task of managing the BLE is very complex for me. Do you have any advice?
Thank you in advance.
GAUBERT36

Related

[Q] First program (error message)

Hi, i know a little bit of java so i was thinking start to create program to my android phone.
but even "hello world" program can't run, i get message:
An internal error occurred during: "Launching New_configuration".
Path for project must have only one segment.
How to fix this ?
Thanks
so no one knows how to fix this ?
I might be helpfull if you would've posted the code you have
it's from google site android hello world program
nevertheless :
package com.android.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}

[APP]2 java files dosen't work

Hi people.
I'm new in JAVA develop, and I'm trying do a simple game.
I tryed to work with 2 separated java files, but I don't know what I'm doing wrong. Example:
File "TesteActivity.java"
package pack.teste;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class TesteActivity extends Activity {
test1 test = new test1();
public TextView text;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text = (TextView)findViewById(R.id.maoe);
text.setText(test.hahae);
}
}
File "test1.java"
package pack.teste;
public class test1 {
TesteActivity test = new TesteActivity();
public String hahae = "maoe";
}
And dosen't work. Somebody can help me?
Thanks

[Q] google map v1

Hi,
I am trying to load google map v1 on android application but only able to see grid. no map. Guide please what thing i am missing?
My main activity file is:
**************************************************************************
package com.example.mymapactivity;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class MyMapActivity extends Activity {
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
private GoogleMap map;
@suppressLint("NewApi")
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_map);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
}
@override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my_map, menu);
return true;
}
}
Please guide
Thanks

[Q] WebView app opens up default browser.

Hello I am a Android newbie and I am currently learning how to code applications using Eclipse so I made one yesterday using webview on eclipse but everytime I open the app it takes me to the website but on my default browser. I want the website to open up in the app not on my browser. Anyone know how to fix this?
You need to read the WebView Reference on Android.
Apparently you open the website on a Intent, so the website is opened on the default browser.
Instead, you need to make you Activity act as a WebView on the 'onCreate()' :
Code:
WebView webview = new WebView(this);
setContentView(webview);
And then open the website :
Code:
// Simplest usage: note that an exception will NOT be thrown
// if there is an error loading this page (see below).
webview.loadUrl("my_url");
// OR, you can also load from an HTML string:
String summary = "<html><body>You scored <b>192</b> points.</body></html>";
webview.loadData(summary, "text/html", null);
// ... although note that there are restrictions on what this HTML can do.
// See the JavaDocs for loadData() and loadDataWithBaseURL() for more info.
Um this is my MainActivity.java
package com.graaltailor.JFA;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends Activity {
WebView mWebView;
/** Called when the activity is first created. */
@override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("examplewebsite");
}
}
You need to do something like this to overwrite urlredirect opened in the default browser :
Code:
package com.graaltailor.JFA;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends Activity {
WebView mWebView;
/** Called when the activity is first created. */
@override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("examplewebsite");
}
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url){
// do your handling codes here, which url is the requested url
// probably you need to open that url rather than redirect:
view.loadUrl(url);
return false; // then it is not handled by default action
}
});
}
I replaced the code with the one you replied with and I get a bunch of errors.
sorry I made a mistake in the code
Code:
package com.graaltailor.JFA;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends Activity {
WebView mWebView;
/** Called when the activity is first created. */
@override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("examplewebsite");
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
// do your handling codes here, which url is the requested url
// probably you need to open that url rather than redirect:
view.loadUrl(url);
return false; // then it is not handled by default action
}
});
}
}

[Q] PreferenceActivity with Checkboxpreference

Hello,
I am french , excuse me for me english .
I'm beginner in java, I begin to make a class for preferences (PreferenceActivity) however I do not know how to implement this type of a class checkboxpreference. For example if possible I would like it like this:
Code:
if (IsChecked) {
Toast.makeText (getApplicationContext (), "On", Toast.LENGTH_LONG) show ().
} Else {
Toast.makeText (getApplicationContext (), "Off", Toast.LENGTH_LONG) show ().}
.
My class :
Code:
package com.root.tools.open;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.;
import android.content.;
import android.util.;
import android.widget.CompoundButton.;
import android.view.;
import android.preference.;
public class Preference extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference);
}}
How implent this method ?
Thank You so much !

Categories

Resources