Skip to content

Sample app used to demonstrate the DeepLinking feature of Clock-In app.

Notifications You must be signed in to change notification settings

totvslabs/samples-mobile

Repository files navigation

Deep Linking for Android

Android app created to sending/receiving data using the Deep Linking.

Requirements

Steps to Run

  1. Install JDK 8.

  2. Install Android Studio and setup an emulador.

  3. Open the Android Studio and build.

Clock-In Integration

Sending data to login with email/password:

public final class MyActivity extends AppCompatActivity {

   private void sendDataToClockIn() {
      Uri.Builder builder = new Uri.Builder()
         .scheme("clockin")
         .authority("login")
         .appendPath("oauth2")
         .appendQueryParameter("organization", organization)
         .appendQueryParameter("environment", environment)
         .appendQueryParameter("email", email)
         .appendQueryParameter("password", password)
         .appendQueryParameter("appScheme", appScheme)
         .appendQueryParameter("appName", appName)
         .appendQueryParameter("appIdentifier", appIdentifier);

      final Uri uri = builder.build();

      Intent intent = new Intent(Intent.ACTION_VIEW, uri);
      intent = intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                               | Intent.FLAG_ACTIVITY_CLEAR_TASK
                               | Intent.FLAG_ACTIVITY_NO_HISTORY);

      final PackageManager packageManager = mContext.getPackageManager();
      final List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);

      if (activities.size() > 0) {
         startActivity(intent);
      }
   }
   
}

Receiving data from the latest clock-in(s):

<manifest>
   <application>
      <!-- ... -->

      <activity android:name=".ReceiveDataActivity"
         android:launchMode="singleTask">
         <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="myscheme" android:host="clockin" />
         </intent-filter>
      </activity>

      <!-- ... -->
   </application>
</manifest>
public final class ReceiveDataActivity extends AppCompatActivity {

   @Override
   protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      receiveDataFromClockIn();
   }

   private void receiveDataFromClockIn(final Intent intent) {
      final Intent intent = getIntent();
      if (intent == null) {
         return null;
      }

      final Uri intentData = intent.getData();
      if (intentData == null) {
         return null;
      }

      intent.setData(null);

      final String host = intentData.getHost();
      if (host == null || !host.equals("clockin")) {
         return null;
      }

      final String clockInsStr = intentData.getQueryParameter("data");
      if (clockInsStr == null) {
         return null;
      }

      TypeToken type = new TypeToken<List<ClockInObject>>(){}.getType();
      List<ClockInObject> clockIns = new Gson().toJson(clockInsStr, type);

      // ...
    }

}

public final class ClockInObject {

   @SerializedName("name")
   private String name;

   @SerializedName("data")
   private ClockInDataObject data;
	
}

public final class ClockInDataObject {

   @SerializedName("clockinCoordinates")
   private String clockinCoordinates;

   @SerializedName("clockinDatetime")
   private String clockinDatetime;

   @SerializedName("employeePersonId")
   private String employeePersonId;

   //...
}

For more implementation details just build the example.

Information about deep linking protocol can be found on Wiki.

Change-log

A brief summary of each release can be found on the releases.

License

© TOTVS Labs

Português

About

Sample app used to demonstrate the DeepLinking feature of Clock-In app.

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages