Question

i have develope a programm for android to get rdp connections.

My problem is: When i use ES File Explorer, i can open the rdp-file with "open with and choose RD Client" and it works perfectly, the app will show the login credentials.

In my program there is a button, when i click them it will open the RD Client app and it show a message: The rdp-file is not valid...

here is the code-fragment:

File file = new File("/sdcard1/SRV01.RDP");
Uri data = Uri.fromFile(file);
Intent i = new Intent();       
i.setAction(android.content.Intent.ACTION_VIEW);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setDataAndType(data, "application/*");
startActivity(i);

and my alternative:

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.microsoft.rdc.android");       
Uri data = Uri.parse("file://" + file);
LaunchIntent.setData(data);
LaunchIntent.setType("rdp");
startActivity( LaunchIntent );

I didn't find the failure. I hope there is anyone who can help me.

Was it helpful?

Solution

File file = new File(Environment.getExternalStorageDirectory().getPath() + "/test.rdp");
Uri data = Uri.fromFile(file);

Intent i = new Intent();       
i.setAction(android.content.Intent.ACTION_VIEW);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setDataAndType(data, "application/rdp");
startActivity(i);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top