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
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
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
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
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
In java each import much be available in the same file where an Object is used.
Look at the sample-code (java). At the top of each file you find all used imports
Dim in As Intent
Dim pm As PackageManager
Try
Log(pm.GetVersionCode("com.ubercab"))
in.Initialize(in.ACTION_VIEW, "uber://?action=setPickup&pickup=my_location&client_id=<CLIENT_ID>")
StartActivity(in)
Catch
...
End Try
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
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
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...
Try the above (you'll need a client id).
It takes you to an online login screen...
Maybe I'm mistaken about this, but it APPEARS to be that which I seek...
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