MainActivity.java 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package com.nexilissamplecode;
  2. import android.os.Bundle;
  3. import android.widget.Toast;
  4. import com.facebook.react.ReactActivity;
  5. import com.facebook.react.ReactActivityDelegate;
  6. import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
  7. import com.facebook.react.defaults.DefaultReactActivityDelegate;
  8. import io.nexilis.service.API;
  9. import io.nexilis.service.Callback;
  10. import io.nexilis.service.utils.callback.SimCardDetectionCallback;
  11. import io.nexilis.service.utils.xthunder.FloatingButton;
  12. public class MainActivity extends ReactActivity {
  13. /**
  14. * Returns the name of the main component registered from JavaScript. This is used to schedule
  15. * rendering of the component.
  16. */
  17. @Override
  18. protected String getMainComponentName() {
  19. return "NexilisSampleCode";
  20. }
  21. /**
  22. * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
  23. * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
  24. * (aka React 18) with two boolean flags.
  25. */
  26. @Override
  27. protected ReactActivityDelegate createReactActivityDelegate() {
  28. return new DefaultReactActivityDelegate(
  29. this,
  30. getMainComponentName(),
  31. // If you opted-in for the New Architecture, we enable the Fabric Renderer.
  32. DefaultNewArchitectureEntryPoint.getFabricEnabled());
  33. }
  34. @Override
  35. protected void onCreate(Bundle savedInstanceState) {
  36. super.onCreate(savedInstanceState);
  37. /**
  38. *
  39. * Nexilis provides an API security shield service, which functions to detect threats such as malware, ADB, screencapture, and Sim Swapping.
  40. */
  41. //SECURITY
  42. //SMS
  43. //EMAIL
  44. //SMARTBOT
  45. /*************************************
  46. Connect to our server with your newuniverse.io Account, and implement the required Callback.
  47. Please Subscribe or contact us to get your newuniverse.io Account.
  48. Do not share your newuniverse.io Account or ever give it out to someone outside your organization.
  49. ************************************/
  50. /**
  51. * API.connect (String NexilisAccount, Activity RegisteredActivity, int NexilisButtonMode, boolean UserMayModifyUID, Callback ConnectCallback)
  52. *
  53. * NexilisAccount : Your Nexilis.io Account.
  54. * RegisteredActivity : Android's Activity class that is used to register the Nexilis Button
  55. * NexilisButtonMode : The flag that determines when the Nexilis Button should appear.
  56. * 0 = Disabled Nexilis Button
  57. * 1 = Within registered Activity, (Nexilis Button only appears when users are in the registered activity)
  58. * 2 = Within App (Nexilis Button always appears as long as user is in the App),
  59. * 3 = Always On (Nexilis Button always appears even if the application process is closed)
  60. * UserMayModifyUID : Sets whether users are allowed to change the Nexilis UserID.
  61. * true = enabled,
  62. * false = disabled
  63. * ConnectCallback : The callback interface to be invoked when calling the method connect.
  64. * You need to implement onSuccess(String NexilisUserID) & onFailed(String reasonCode) to handle the RESULT.
  65. *
  66. */
  67. API.connect("***REPLACE***WITH***YOUR***NEXILIS***ACCOUNT***", this, 0, new Callback() {
  68. @Override
  69. public void onSuccess(final String NexilisUserID) {
  70. /**************************************
  71. The NexilisUserID parameter is generated automatically and can be mapped to a User ID on the application level.
  72. For example, the Nexilis User ID (e.g. User001) can be mapped into the corresponding Application User ID (e.g. John Doe),
  73. so you don't have to share your Application User ID with Nexilis while still being able to monitor your user activities.
  74. **************************************/
  75. runOnUiThread(new Runnable() {
  76. @Override
  77. public void run() {
  78. //FLOATING
  79. Toast.makeText(getBaseContext(), "Your User ID: " + NexilisUserID + " : " + getString(io.nexilis.service.R.string.pb_loading), Toast.LENGTH_LONG).show();
  80. }
  81. });
  82. }
  83. @Override
  84. public void onFailed(final String reasonCode) {
  85. /**
  86. * reasonCode : Returns a code based on the status of the function connect called.
  87. * 2:Your trial subscription has expired. Please subscribe to continue using Nexilis.
  88. * 3:Your monthly subscription is not paid in full. Please pay your monthly subscription bill to continue using Nexilis service.
  89. * 4:Your Customer Engagement Credit has run out and your Prepaid Credit Balance is empty. Please top-up your Prepaid Credit Balance to continue using Nexilis
  90. * 23:Unsupported Android version
  91. * 93:Missing the required overlay permission
  92. * 94:Unregistered User
  93. * 95:Invalid Nexilis Button Mode (1,2,3)
  94. * 96:Activity is null
  95. * 97:Account is empty
  96. * 98:Your account didn't match
  97. * 99:Something went wrong
  98. */
  99. runOnUiThread(new Runnable() {
  100. @Override
  101. public void run() {
  102. Toast.makeText(getBaseContext(), reasonCode, Toast.LENGTH_LONG).show();
  103. }
  104. });
  105. }
  106. });
  107. }
  108. }