I am using a Google API for android. Since Google API/G Suite Quickstart for android refers to their java examples, I am trying to implement this:
GoogleAuth
I solved it by myself now. Instead of trying to get the Desktop class from java.awt.Desktop, I just overwrote the on Authorization method:
AuthorizationCodeInstalledApp ab = new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()){
protected void onAuthorization(AuthorizationCodeRequestUrl authorizationUrl) throws IOException {
String url = (authorizationUrl.build());
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
main_Activity.startActivity(browserIntent);
}
};
The reason I did this is because authorize() will call onAuthorization() which will call browse(), which checks if Desktop is supported or not. So by rewriting the onAuthorization() method, I won't need that class anymore. My rewritten class will just start a new Browserwindow with that authorization-URL in your android device.
I hope, I was able to help anyone, who encounteres this problem.