Android Question UBER sdk

Rusty

Well-Known Member
Licensed User
Longtime User
Has anyone integrated the UBER sdk into a B4a project?
If so, can you help get me started in doing so with mine?
Are there any libs that can be used?
All I want to be able to do is provide a "button" click access to UBER ride scheduling...
Thanks,
Rusty
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks Don,
...I have looked over all the UBER interface docs and since I don't "speak" java or Android Studio well, I've spent several hours trying.
I'm not familiar with how to use REST servers and okHTTPUtils...
Is there an example from which I can start?
BTW, I'm trying to integrate it within a B4a project, not B4j or anything else.
Regards,
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks,
Does this mean the class can be modified to point to UBER instead of Dropbox?
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Don,
Thanks for the advice.
For me, the Dropbox port was a failure...not your fault. :)
I'm trying to use the Java functions to get something going, but end up with:
B4A version: 6.31
Parsing code. (0.00s)
Compiling code. (0.05s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Generating R file. (0.17s)
Compiling debugger engine code. (1.51s)
Compiling generated Java code. Error
B4A line: 26
End Sub
javac 1.8.0_51
src\b4a\example\starter.java:190: error: cannot find symbol
PackageManager pm = context.getPackageManager();
^
symbol: class PackageManager
location: class starter
using this code in my Starter service
B4X:
Sub Process_Globals
    Private NativeMe As JavaObject        'use Java to access
End Sub

Sub Service_Create
       NativeMe.InitializeContext
       NativeMe.RunMethod("checkuber", Null)    'run the Java method
End Sub

Sub Service_Start (StartingIntent As Intent)

End Sub

Sub Service_Start (StartingIntent As Intent)

End Sub

Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
End Sub      ******************* THIS IS LINE 26 **********************

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Service_Destroy

End Sub


#if java
import java.net.NetworkInterface;
import java.util.Collections;
import java.util.List;

    public static String checkuber() {
        try {
          PackageManager pm = context.getPackageManager();
          pm.getPackageInfo("com.ubercab", PackageManager.GET_ACTIVITIES);
          String uri =
              "uber://?action=setPickup&pickup=my_location&client_id=<CLIENT_ID>";
          Intent intent = new Intent(Intent.ACTION_VIEW);
          intent.setData(Uri.parse(uri));
          startActivity(intent);
        } catch (PackageManager.NameNotFoundException e) {
          // No Uber app! Open mobile website.
          String url = "https://m.uber.com/sign-up?client_id=<CLIENT_ID>";
          Intent i = new Intent(Intent.ACTION_VIEW);
          i.setData(Uri.parse(url));
          startActivity(i);
        }
    }
#end if
Can someone advise me on what I'm doing wrong with this?
Thanks,
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks Don,
Unfortunately, Gradle nails me in my Android studio and i can get nowhere using studio...
I've tried using Uber's example code directly ... if I could control their IDE/environment I could probably follow your advice.
I have no idea how to see the needed imports...
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
B4X:
#if java

import android.content.pm.PackageManager;
import java.net.NetworkInterface;
import java.util.Collections;
import java.util.List;

      public static String checkuber() {
        try {
          PackageManager pm = context.getPackageManager();
          pm.getPackageInfo("com.ubercab", PackageManager.GET_ACTIVITIES);
          String uri =
              "uber://?action=setPickup&pickup=my_location&client_id=<CLIENT_ID>";
          Intent intent = new Intent(Intent.ACTION_VIEW);
          intent.setData(Uri.parse(uri));
          startActivity(intent);
        } catch (PackageManager.NameNotFoundException e) {
          // No Uber app! Open mobile website.
          String url = "https://m.uber.com/sign-up?client_id=<CLIENT_ID>";
          Intent i = new Intent(Intent.ACTION_VIEW);
          i.setData(Uri.parse(url));
          startActivity(i);
        }
    }
#end if

B4A version: 6.31
Parsing code. (0.00s)
Compiling code. (0.06s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.00s)
Generating R file. (0.16s)
Compiling debugger engine code. (1.58s)
Compiling generated Java code. Error
B4A line: 24
End Sub
javac 1.8.0_51
src\b4a\example\starter.java:192: error: cannot find symbol
PackageManager pm = context.getPackageManager();
^
symbol: variable context
location: class starter
Thanks Don, I'm about at my wits end on this... I appreciate your help!
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks Erel,
It is giving me the error:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=uber://?action=setPickup&pickup=my_location&client_id=<Clientid>flg=0x20000 }
I have an activity running with a WebViewer1 embedded within the layout.
I'd like to use the WebViewer to "view" the intent results (which is an Uber webpage)
Rusty
 
Last edited:
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
No.
The idea of the intent is to invoke a screen made available to users on UBER that doesn't require the app to be installed.
I have a client (a medical clinic with many patients) who wishes to allow their patients to use the tablet (when finished with it) to arrange a ride.
Each patient will need an account, but, once through booking the ride, the account information, name etc. must be destroyed.
My approach is to use their web interface without installing UBER.
I can invoke the installed intent already, but wish to use the webview to do the above.
Thanks for your continued support
Rusty
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
which is an Uber webpage
i´m not sure you are right.

The code you posted searches for the uber app and start an intent to this app. Whatever this app may show...
it is not a website you can show inside your app.

In fact you want to start the Uber app with the code.
And it is the Uber app which shows something after it got started...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The idea of the intent is to invoke a screen made available to users on UBER that doesn't require the app to be installed.
You know you can check the existence of the Uber app with the B4A Pakagemanager?
Use the PM. check for the app. If it does not exist you point the user to show the webpage
B4X:
 String url = "https://m.uber.com/sign-up?client_id=<CLIENT_ID>";
 
Upvote 0
Top