I am trying to make an intent that starts skype conversation with a certain person. Having looked through it all over the stackoverflow, I still cannot make it work properly. Here's my code:
String skypeUri = "skype:name?chat";
Intent intent = new Intent();
intent.setData(Uri.parse(skypeUri));
intent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
My intent filter:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<data android:scheme="skype" />
</intent-filter>
It brings me to skype but only to the main page of it, no conversation is opened.
Any help would be appreciated.
just use below code
Intent skypeIntent = new Intent("android.intent.action.VIEW");
skypeIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
skypeIntent.setData(Uri.parse("skype:" + skypeId + "?chat"));
Assuming that is your exact code, the problem is that you are not passing the username of the person you want to call. You just have 'name' where their username should be. You need something like:
String skypeUri = "skype:"+username+"?chat";
Related
I have an intent-filter that open all links with host "xyzxyz.com/value".
In the manifest I set an Activity to receive it:
<activity
android:name=".ui.LinkOpenerActivity"
android:label="#string/app_name" >
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="xyzxyz.com" />
</intent-filter>
</activity>
So when the user click on a "xyzxyz.com/value" link it open the app, that execute certain operations based on the "value" in the URL.
What I would like to do is to open the default browser in case the "value" have an incorrect value.
I tried with
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlReceivedFromIntent));
startActivity(browserIntent);
but it end up in an infinite loop, because it open again my app... any suggestion to fallback in the default browser and open http://xyzxyz.com/value in it?
Solved with Intent chooser:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(
Intent.createChooser(browserIntent, null)
);
finish();
By using context.getPackageManager().queryIntentActivities you can get the list of the activities that are able to resolve your intent. You can then filter out yours and pick another one explicitly by using Intent.setClassName (or force a chooser by using Intent.createChooser)
I want to list apps (with same intent filter). I was able to achieve this by adding intent filter to an activity
<activity
android:name=".Activities.MainActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustNothing">
<intent-filter>
<action android:name="com.example.identifier" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="isApp" />
</intent-filter>
</activity>
and i could retrieve all apps having this intent with
String uri = "isApp:";
Intent intent = new Intent("com.example.identifier",
Uri.parse(uri));
PackageManager manager = getPackageManager();
List<ResolveInfo> list = manager.queryIntentActivities(intent, 0);
However, this launches the activity when shown in intentChoose using this snippet:
Intent zoneIntent = new Intent("com.example.identifier",
Uri.parse(uri));
Intent openInChooser = Intent.createChooser(zoneIntent, "Complete Action with").setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(openInChooser);
But i would want this to call a broadcast receiver. So, i moved the intent to a broadcast receiver in AndroidManifest.xml like:
<receiver
android:name=".ExampleReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.example.identifier" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="isApp" />
</intent-filter>
</receiver>
and the snippet that returns the number of apps with this intent returns 0 now even when the app is still on this device. Could this be done with Broadcast receiver or should i consider with another approach. Thanks.
Calling queryIntentActivities() will only return Activitys. It won't return BroadcastReceivers. If you want to do this with BroadcastReceivers, then you need to call queryBroadcastReceivers() instead.
I have two android apps(i.e. BIApp and EApp) and I am trying to open EApp from BIApp.
EApp has two activity one is MainActivity and another is LandingPageActivity.
When I try to launch MainActivity using startActivity(intent) it works fine but if I try to launch LandingPageActivity. startActivity(intent) does nothing.
if EApp is open in background then startActivity(intent) works for LandingPageActivity too.
Below is the code snippet that I am using.
Intent intent = new Intent();
intent.setClassName("com.pkg.eapp", "com.pkg.eapp.LandingPageActivity");
startActivity(intent);
I want to start LandingPageActivity.
What should I do ?
Try this:
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.pkg.eapp", "com.pkg.eapp.LandingPageActivity"));
startActivity(intent);
and add
android:exported="true"
and in the intent-filter add
<category android:name="android.intent.category.DEFAULT"/>
to the declaration of LandingPageActivity in the manifest.
Try this, this is working for me
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.pkg.eapp", "com.pkg.eapp.LandingPageActivity"));
startActivity(intent);
Read how to allow Other Apps to Start Your Activity
You only need to add android.intent.category.DEFAULT category to your Activity onto manifest. Like below
<activity android:name="com.pkg.eapp.LandingPageActivity">
<intent-filter>
<action android:name="com.pkg.eapp.action.OPEN_LANDING_PAGE" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
and call it as
Intent intent = new Intent("com.pkg.eapp.action.OPEN_LANDING_PAGE");
intent.setComponent(new ComponentName("com.pkg.eapp", "com.pkg.eapp.LandingPageActivity"));
// Or intent.setPackage("com.pkg.eapp");
startActivity(intent);
I have never done this but may be LandindPageActivity is not accessible by other apps. In your EApp manifest, do you have an intent filter like this for the LandingPageActivity ?
<intent-filter>
<action android:name="com.pkg.eapp.LandingPageActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Try this:
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.pkg.eapp.LandingPageActivity");
startActivity(LaunchIntent);
Hope this might help you.
I would like to receive intents with the action VIEW
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
And I want to start other apps with intents with the same action VIEW
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "application/pdf");
context.startActivity(intent);
But I dont't want to start my own activity. I want that the user sees the standard list of activities that can receive the intent.
How can I acomplish this?
you can create a chooser for your intent
Intent chooser = Intent.createChooser(intent, "randome title");
or make your code like this
context.startActivity(Intent.createChooser(intent, "randome title"));
I have a service running that will put a notification on the notification bar on a particular event. In that notification I'm setting a PendingIntent to launch another application. For some reason when I act on the notification it doesn't launch the other application. Here is the code where I create the PendingIntent.
private PendingIntent externalAppStartIntent(LaunchInfo launchInfo) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName(launchInfo.getPackageName(), launchInfo.getActivityName());
intent.setData(launchInfo.toUri());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return PendingIntent.getActivity(this, ZONE_SERVICE_START_EXTERNAL_APP, intent,
PendingIntent.FLAG_CANCEL_CURRENT);
}
I am able to launch the app using a regular Intent elsewhere in my code like this.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName(packageName, activityName);
intent.setData(data);
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
ZoneUtils.launchMarketDialog(getActivity(), packageName);
}
I've checked to make sure the values of the variables I'm sending in both cases are the same.
Note that I'm trying to launch an Activity in another application outside of the one where this code lives.
EDIT:
Here is the activity definition from the other apps manifest.
<activity
android:name=".ui.GalleryActivity"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="join"
android:path="/"
android:scheme="mgp" />
</intent-filter>
</activity>
EDIT2:
Here is the log I get when I act on the notification
04-20 19:05:59.151: I/ActivityManager(193): START {act=android.intent.action.VIEW cmp=com.brockoli.magnet.photoapp/.ui.GalleryFragment bnds=[128,418][720,546]} from pid -1
David Suppiger spotted it!
I was accidentally passing my GalleryFragment instead of my GalleryActivity. Working great now! Ty