I am using the Cast Companion Library and it is mostly working fine, I get the mini player, and also the lock screen controls and the activity for playing content, but I can never get the notification screen to show. I am doing the following when initializing:
mCastMgr.enableFeatures(VideoCastManager.FEATURE_NOTIFICATION |
VideoCastManager.FEATURE_LOCKSCREEN |
VideoCastManager.FEATURE_DEBUGGING);
and I am doing the incrementUiCounter() on resume and decrementUiCounter() on pause.
I don't see any errors, I just don't see what I am doing wrong. The only thing I am missing is that I am not passing URLs for images when telling media to play because my URLs are local assets to my app and I'm just not sure how to pass those.
Are you using that with your own app or with CastVideos-android? If your own app, first I suggest you try the CastVideos-android app to make sure that works for you.
I suggest you print out the value of mVisibilityCounter in BaseCastManager.incrementUiCounter() and decrementUiCounter() to see if as you move in and out of different activities, it reflects the correct counter. When that counter reaches zero, then notification should show up. If the counter is reaching zero and the notification doesn't show up, I suggest you check your manifest file and see if you have the following in your Manifest:
<service
android:name="com.google.sample.castcompanionlibrary.notification.VideoCastNotificationService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.sample.castcompanionlibrary.action.toggleplayback" />
<action android:name="com.google.sample.castcompanionlibrary.action.stop" />
<action android:name="com.google.sample.castcompanionlibrary.action.notificationvisibility" />
</intent-filter>
</service>
(you can copy-and-paste from the CastVideos-android manifest file). You may have grabbed what it is from the documentation; there is an error there (I am planning to update a bunch of things tonight or tomorrow and the documentation will be updated as well); basically when the counter reaches zero, it calls into the notification service (see the onUiVisibilityChanged() in VideoCastManager) and if that action in manifest is not correctly set, the notification never gets our memo! Let me know if that is not the issue.
I had the same trouble. Just an FYI to those looking at this in 2016. The manifest entry is now different. I suggest to grab whatever is in the manifest of the CastVideos-android project.
<receiver android:name="com.google.android.libraries.cast.companionlibrary.remotecontrol.VideoIntentReceiver" />
<service
android:name="com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService" />
<service android:name="com.google.android.libraries.cast.companionlibrary.cast.reconnection.ReconnectionService"/>
Related
My app is designed to work with various Amazon links but for some reason it has started to always open links instead of the Android system asking every time.
If I click a link on the Amazon website in Chrome my app opens. If I click an Amazon link in an email my app opens.
In my settings I have Android set to Ask every time for Amazon (see screenshot) but it's acting as though it is set as the default.
What's odd is that my app didn't used to do this, and it sometimes doesn't do it now (though only very occasionally) and instead asks as you would expect. But 95% of the time my app launches automatically.
Now I'm getting reports from users of the same thing.
Is it possible for something in the manifest to cause this (I wouldn't have thought so as that could effectively allow app hijacking) or are my OS settings (and those of the users reporting the problem) messed up?
Manifest.xml below:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.nooriginalthought.amalfi">
<uses-permission android:name="android.permission.INTERNET"/>
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher" android:label="AmALfi" android:largeHeap="true" android:resizeableActivity="true" android:supportsPictureInPicture="true" android:theme="#style/AppTheme">
<activity android:name="com.nooriginalthought.amalfi.MainActivity" android:configChanges="orientation|screenSize" android:screenOrientation="portrait" android:launchMode="singleTop" android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:label="#string/generate_affiliate_link_with_amalfi">
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
<intent-filter android:label="#string/generate_affiliate_link_with_amalfi">
<action android:name="android.intent.action.SENDTO"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:host="*.amazon.ae" android:scheme="http"/>
<data android:host="*.amazon.ae" android:scheme="https"/>
<data android:host="*.amazon.ca" android:scheme="http"/>
<data android:host="*.amazon.ca" android:scheme="https"/>
<data android:host="*.amazon.co.uk" android:scheme="http"/>
<data android:host="*.amazon.co.uk" android:scheme="https"/>
<data android:host="*.amazon.com" android:scheme="http"/>
<data android:host="*.amazon.com" android:scheme="https"/>
<data android:host="*.amazon.com.au" android:scheme="http"/>
<data android:host="*.amazon.com.au" android:scheme="https"/>
<data android:host="*.amazon.com.br" android:scheme="http"/>
<data android:host="*.amazon.com.br" android:scheme="https"/>
<data android:host="*.amazon.com.mx" android:scheme="http"/>
<data android:host="*.amazon.com.mx" android:scheme="https"/>
<data android:host="*.amazon.de" android:scheme="http"/>
<data android:host="*.amazon.de" android:scheme="https"/>
<data android:host="*.amazon.es" android:scheme="http"/>
<data android:host="*.amazon.es" android:scheme="https"/>
<data android:host="*.amazon.fr" android:scheme="http"/>
<data android:host="*.amazon.fr" android:scheme="https"/>
<data android:host="*.amazon.in" android:scheme="http"/>
<data android:host="*.amazon.in" android:scheme="https"/>
<data android:host="*.amazon.it" android:scheme="http"/>
<data android:host="*.amazon.it" android:scheme="https"/>
<data android:host="*.amazon.jp" android:scheme="http"/>
<data android:host="*.amazon.jp" android:scheme="https"/>
</intent-filter>
<intent-filter android:label="#string/generate_affiliate_link_with_amalfi">
<action android:name="android.intent.action.VIEW"/>
<data android:host="*.amazon.ae" android:scheme="http"/>
<data android:host="*.amazon.ae" android:scheme="https"/>
<data android:host="*.amazon.ca" android:scheme="http"/>
<data android:host="*.amazon.ca" android:scheme="https"/>
<data android:host="*.amazon.co.uk" android:scheme="http"/>
<data android:host="*.amazon.co.uk" android:scheme="https"/>
<data android:host="*.amazon.com" android:scheme="http"/>
<data android:host="*.amazon.com" android:scheme="https"/>
<data android:host="*.amazon.com.au" android:scheme="http"/>
<data android:host="*.amazon.com.au" android:scheme="https"/>
<data android:host="*.amazon.com.br" android:scheme="http"/>
<data android:host="*.amazon.com.br" android:scheme="https"/>
<data android:host="*.amazon.com.mx" android:scheme="http"/>
<data android:host="*.amazon.com.mx" android:scheme="https"/>
<data android:host="*.amazon.de" android:scheme="http"/>
<data android:host="*.amazon.de" android:scheme="https"/>
<data android:host="*.amazon.es" android:scheme="http"/>
<data android:host="*.amazon.es" android:scheme="https"/>
<data android:host="*.amazon.fr" android:scheme="http"/>
<data android:host="*.amazon.fr" android:scheme="https"/>
<data android:host="*.amazon.in" android:scheme="http"/>
<data android:host="*.amazon.in" android:scheme="https"/>
<data android:host="*.amazon.it" android:scheme="http"/>
<data android:host="*.amazon.it" android:scheme="https"/>
<data android:host="*.amazon.jp" android:scheme="http"/>
<data android:host="*.amazon.jp" android:scheme="https"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity android:name="com.nooriginalthought.amalfi.ManageAffIdsActivity" android:configChanges="orientation|screenSize" android:screenOrientation="portrait" android:theme="#style/AppTheme"/>
<activity android:name="com.nooriginalthought.amalfi.PreviewLinkActivity" android:configChanges="orientation|screenSize" android:screenOrientation="portrait"/>
</application>
</manifest>
You have set one activity for android:mimeType="text/plain" and as Browser.
Split both in owns Activities
You have probably set that your app is standard for text/plain and so it will be always opening as browser
Well, just like the title suggests, every activity within my application is being added to the app drawer.... Im really hating this new ADT. First it was a problem with the app name appearing as the first activity name, now all the activities are showing up on the application list. If I go to uninstall it only shows 1. Anyone else having this problem and has figured out a work around?
for future cases specifically you can change in the android manifest under :
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
change to:
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
This will remove the activities' icon from the app drawer. As the OP says: sometimes the wizard puts this in the manifest for you.
Ok, figured it out... Everytime you create a new activity through the adt wizard (New -> Android Activity) it creates the code in your manifest for you.... the problem is that it added intent filters to it as well. Just remove those and they dont show up.... stupid adt.
I know when I am using IntelliJ as my IDE for Android programming, there is a box you can check when using the wizard to create a new Activity that says "Mark as start-up Activity".
Be aware of these types of things because that is what caused me to have the same problem you had Shaun.
I wouldn't completely erase the intent filters, simply have only the Activity you want as the "start-up" Activity marked as the "Launcher" in the Manifest file. All other Activities get "Default".
i have an application which associates pdf files in my Manifest(via intent-filters), so when someone click on pdf link in the default browser i can execute that action with my app and download it with a progressbar. my question is, is it a way that i can associate other files but not "hard coded" in my manifest, but to let the user choose(or write) that file extention in preferences for example and i can add it dynamically from code. i know that probably this can be done with broadcast receiver but cant find any examples or simple code for that matter. ive seen preference menu like that in bsplayer settings .. but cant post image cuz dont have enough reputation.
I will try to explain more detailed my problem, because i think that there was some misunderstanding with the answer below.
i have an application which have the fallowing code in my manifest.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.pdf" />
</intent-filter>
2.i launch my app which registers .pdf files with it. so next time i click on pdf link in my browser, a window pops up, making me choose with what application should i complete that action. if i choose my application, my main activity is launched, in which i use getIntent() and my app downloads the file using progressbar.
3.the problem is that i want to download and other files like that ie. jpg, png .. etc, but giving the user a choice which ones, or even making him write the extentions for the files he wants to download using my application if clicks on link somewhere that leads to that kind of files.
4.to make this thing happen, file extensions should be added dynamically in code somewow and not in manifest. i was looking some examples for broadcast receiver, since that class can use IntentFilter class, but cant really understand what i should be doing with it.
5.My main goal: starting my app, there is layout with some spinner or edit box. the user choose/writes some extension (.dwf). that extension is now registered with my app. if the next time the user browsing internet clicks on link which leads to .dwf file he could choose to continue the action with my app. and the file should be downloaded just like the .pdf
6.sry for my bad english and some help will be appreciated. also code ;)
boolean enabled=prefs.getBoolean(key, false);
int flag=(enabled ?
PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
ComponentName component=new ComponentName(MyActivity.this, TargetActivity.class);
getPackageManager()
.setComponentEnabledSetting(component, flag,
PackageManager.DONT_KILL_APP);
Depending upon your preference you can Disable the activity that handles the File type in your BOOT_COMPLETED Reciever. I Believe you will have to have different activities to handle different file types and then disable selectively
We are localizing our app to be able to easily switch between languages. Everything works nicely except for some cached values that are actually in navigation. We have two options:
completely restart app on language change - in this case I need a notification and force restart
just load new strings into the table - in this case it will require to replace string values and rbuild custom navigation state.
IN both cases we need a way to find out when language switches. Is there an intent we can listen to? If yes could you please advise on which one? I am thinking to go with a broadcast receiver. I am just not sure which intent action it is. In below example what is the SOME_ACTION value?
Thanks in advance.
<receiver android:name="com.v1.application.notifications.LanguageChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.SOME_ACTION" />
</intent-filter>
</receiver>
android.intent.action.CONFIGURATION_CHANGED
The documentation says you can specify a custom category.
When, why and how would you do it?
What would be the use of it?
The way I understand it, categories are public directives to the android operating system(and other apps) that represent different categories that your app should be a part of.
Example
When the launcher icon is tapped on the home screen, the home application looks through every installed app's manifest for the HOME category -- and if so it displays it in the app drawer.
However, there's more. You can specify categories in your applications manifest that lets the system know that you application can handle the intent category. For example, by putting a ALTERNATIVE category, other apps in the system know that your app can handle that category without specifically knowing the action name! In the following example, custom intent categories are passed through this intent, which is filtered and the corresponding object gets edited(taken from the Notes example app):
<intent-filter android:label="#string/resolve_title">
<action android:name="com.android.notepad.action.EDIT_TITLE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.ALTERNATIVE" />
<category android:name="android.intent.category.SELECTED_ALTERNATIVE" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
By registering this intent filter in an <activity /> tag, you can edit a "note". The intent data would contain the note, and the intent would get routed to the activity that this filter is registered in.
In Conclusion:
There isn't really a reason you'd use a custom category. They are for Android, and thus don't really make sense in application use. But, if you choose to use them, they can be used in the methods described above. "They provide some specific semantic rules, and if those rules are useful to you then feel free to use them"(Hackbod).
http://developer.android.com/guide/topics/intents/intents-filters.html
Scroll down a bit and you should see a section under "Intent Objects"
They basically describe certain special properties of an activity. for example, adding
<category android:name="android.intent.category.HOME" />
means that the app can be started on the phone's bootup
I'm kinda a noob to Android still, although I have programming experience otherwise.. It says a custom category in your own namespace. I'm guessing that if you are programming multiple apps and you want one app to run another app, you could use a custom category for your intent to force the phone to find your other app to catch the intent with?
When you do not want to use the default category then use the custom category.
Custom categories should use the package name as a prefix, to ensure that they are unique.
Some information is provided on below link:
http://developer.android.com/guide/topics/manifest/category-element.html
Check the below link it has somewhat same question:
Android custom categories