I have implemented a Button in my Mobile Application und have a Textfieldwith a Telefon Nummer.
What i want to achieve: When the User Click the Button-> The Default Page to send SMS is open in Android and the Telefonnummer is Paste in the default Nummer Textfield for Android.
I Use Gluon Mobile with JavaFX
:compileJava/Users/yotti/CAMVOYAGE/MultiViewProjectFXML/src/main/java/com/gluonapplication/views/AndroidSMSService.java:4: error: package android.content does not exist
import android.content.Intent;
^
/Users/yotti/CAMVOYAGE/MultiViewProjectFXML/src/main/java/com/gluonapplication/views/AndroidSMSService.java:5: error: package android.net does not exist
import android.net.Uri;
^
/Users/yotti/CAMVOYAGE/MultiViewProjectFXML/src/main/java/com/gluonapplication/views/AndroidSMSService.java:12: error: cannot find symbol
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
^
symbol: class Intent
location: class AndroidSMSService
/Users/yotti/CAMVOYAGE/MultiViewProjectFXML/src/main/java/com/gluonapplication/views/AndroidSMSService.java:12: error: cannot find symbol
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
^
symbol: class Intent
location: class AndroidSMSService
/Users/yotti/CAMVOYAGE/MultiViewProjectFXML/src/main/java/com/gluonapplication/views/AndroidSMSService.java:12: error: cannot find symbol
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
^
symbol: variable Intent
location: class AndroidSMSService
/Users/yotti/CAMVOYAGE/MultiViewProjectFXML/src/main/java/com/gluonapplication/views/AndroidSMSService.java:13: error: cannot find symbol
smsIntent.setData(Uri.parse("sms:"));
^
symbol: variable Uri
location: class AndroidSMSService
/Users/yotti/CAMVOYAGE/MultiViewProjectFXML/src/main/java/com/gluonapplication/views/AndroidSMSService.java:15: error: cannot access Activity
FXActivity.getInstance().startActivity(smsIntent);
^
class file for android.app.Activity not found
7 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I suggest you have a look at how the Charm Down plugins are implemented.
You will see that you can use most of the existing services without further modifications.
If the service you are looking for is not implemented yet, it is really easy to create it, following the same guidelines as the existing plugins:
On your source packages [Java], add the following classes:
Package:
com.gluonhq.charm.down.plugins
. Class:SMSService
:Package:
com.gluonhq.charm.down.plugins
. Class:SMSServiceFactory
:Finally, on the Android package, implement the service:
Package:
com.gluonhq.charm.down.plugins.android
, class:AndroidSMSService
Test
Now all you need to do is use the SMS service in your code, once you have the number added to the textField, and a button to fire the action:
Build the application and deploy it to your Android device. Try it, and check that it opens the Messenger app (maybe it will ask to use other different apps), and already uses the provided number, so you can start typing your message.