Question

D'accord, je décompilé Skype de manifeste pour savoir s'il y a des services ou radiodiffusions en cours d'exécution pendant un appel. Il n'y a que quelques émissions internes pour les appels entrants. Aussi un seul récepteur et un exist service.

J'ai suivi tous les services en cours d'exécution avec mon application, mais le SkypeMainService est toujours en cours d'exécution, même si pas dans un appel.

En outre AudioMode ne change pas par skype (mais selon les logcat-logs le dev voulait, mais ils ne le font pas), donc je ne peux pas simplement vérifier si elle est MODE_IN_CALL.

Avez-vous des suggestions pour savoir si Skype est en cours d'exécution et d'avoir un appel actif?

Merci!

/ edit: Un bref aperçu des activités etc:

<activity android:name="com.skype.raider.Main">
<activity-alias android:name="com.skype.raider.ui.SplashScreenActivity" android:targetActivity="com.skype.raider.Main">
<receiver android:name="com.skype.MainReceiver" android:enabled="true" android:exported="false">
   <action android:name="android.intent.action.BOOT_COMPLETED" />
   <action android:name="android.intent.action.MEDIA_MOUNTED" />
   <action android:name="android.intent.action.SEARCH" />
   <action android:name="android.intent.action.CALL_PRIVILEGED" />
   <action android:name="com.skype.raider.INCOMING_GSM_CALL" />
   <action android:name="com.skype.raider.ON_GSM_CALL" />
   <action android:name="com.skype.raider.intent.action.request_sync" />
</receiver>
<service android:name="com.skype.MainService">
Était-ce utile?

La solution

Okay, I really hoped someone would provide a useful answer. However, I picked up Reuben's advice in the comment and made this method:

/**
 * Gets the current activity
 * 
 * @param context
 *            A context to use
 * @return The Activity name
 */
public static String getCurrentTopActivity(Context context) {
    ActivityManager mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningTaskInfo> RunningTask = mActivityManager.getRunningTasks(1);
    ActivityManager.RunningTaskInfo ar = RunningTask.get(0);
    return ar.topActivity.getClassName().toString();
}

Then I check if the result equals com.skype.raider.Main. This will also return true if there is no active Skype call, but the main app is open.

Thanks for all the help, especially Reuben!

Edit: Your will need the following permission in your manifest

<uses-permission android:name="android.permission.GET_TASKS"/>

Autres conseils

The day Skype changes any of this (might be in that update that's coming in 2 days from now - before you finish coding) your code might break. So I don't think its worth attempting anything of this sort.

I am sorry, this might not be an "answer", but I don't think time invested into this is worth it.

There is a few things that you can do to increase your chance of guessing it:

1) Check if the application is running:

ActivityManager activityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE );
    List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();
    for(int i = 0; i < procInfos.size(); i++){
        if(procInfos.get(i).processName.equals("com.android.browser")) {
            Toast.makeText(getApplicationContext(), "Browser is running", Toast.LENGTH_LONG).show();
        }
    }

2) Check the phone state for data exchanging using the PhoneManager

3) and finally check Skype developers page for any known api

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top