Android Flurry Integration with admob ads - android

I am integraing admob with flurry. I am receiving test ads from flurry. I add goggle services and added following activities
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<meta-data
android:name="com.flurry.admob.MY_AD_UNIT_ID"
android:value="#string/appSpot_admob_apikey" />
<meta-data
android:name="com.flurry.admob.test"
android:value="true" />
<meta-data
android:name="com.flurry.admob.MYTEST_AD_DEVICE_ID"
android:value="#string/appSpot_admob_testdevicekey" />
<meta-data
android:name="com.flurry.admob.test"
android:value="false" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.flurry.example.ad.mediated.all.BannerAdsActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.flurry.example.ad.mediated.all.InterstitialAdsActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
</application>
Here is my catlog errors
07-16 14:52:57.437: E/FlurryAgent(9247): AdMob: package="com.flight.flight_app2": AndroidManifest.xml should include meta-data node with android:name="com.flurry.gms.ads.MY_AD_UNIT_ID" and not empty value for android:value
07-16 14:52:57.437: E/FlurryAgent(9247): Cannot create ad network view for type: AdMob
07-16 14:52:57.437: W/FlurryAgent(9247): Failed to create view for ad network: AdMob, network is unsupported on Android, or no ICustomAdNetworkHandler was registered or it failed to return a view.
07-16 14:53:03.804: I/ViewRootImpl(9247): ViewRoot's MotionEvent : Down
Thanks in advance.

Well, your error message says:
AndroidManifest.xml should include meta-data node with android:name="com.flurry.gms.ads.MY_AD_UNIT_ID" and not empty value for android:value
So I would start by adding that.

Related

java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException

Suddenly, I tried to open my application and the app did not wanted to start. It stopped before opening it. I started searching and tried all of other similar questions, but none worked. this is my log:
2020-07-18 22:27:41.652 21042-21042/? I/art: Not late-enabling -Xcheck:jni (already on)
2020-07-18 22:27:41.652 21042-21042/? W/art: Unexpected CPU variant for X86 using defaults: x86
2020-07-18 22:27:41.878 21042-21042/? W/System: ClassLoader referenced unknown path: /data/app/com.ainimei.remotemouse-1/lib/x86
2020-07-18 22:27:41.900 21042-21042/? D/AndroidRuntime: Shutting down VM
2020-07-18 22:27:41.900 21042-21042/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ainimei.remotemouse, PID: 21042
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException:
******************************************************************************
* The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers *
* should follow the instructions here: *
* https://googlemobileadssdk.page.link/admob-android-update-manifest *
* to add a valid App ID inside the AndroidManifest. *
* Google Ad Manager publishers should follow instructions here: *
* https://googlemobileadssdk.page.link/ad-manager-android-update-manifest. *
******************************************************************************
at android.app.ActivityThread.installProvider(ActivityThread.java:5856)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5445)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5384)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.IllegalStateException:
******************************************************************************
* The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers *
* should follow the instructions here: *
* https://googlemobileadssdk.page.link/admob-android-update-manifest *
* to add a valid App ID inside the AndroidManifest. *
* Google Ad Manager publishers should follow instructions here: *
* https://googlemobileadssdk.page.link/ad-manager-android-update-manifest. *
******************************************************************************
at com.google.android.gms.internal.ads.zzyz.attachInfo(com.google.android.gms:play-services-ads-lite##19.2.0:33)
at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(com.google.android.gms:play-services-ads-lite##19.2.0:3)
at android.app.ActivityThread.installProvider(ActivityThread.java:5853)
... 10 more
here is my androidManifest.xml:
note that the code has no meta-data tag. But I never needed it until now. Also my app does not use ads on it.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ainimei.remotemouse">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="#drawable/ainimei_logo_icon"
android:label="#string/app_name"
android:roundIcon="#drawable/ainimei_logo_icon"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".SelectConnectionType" />
<activity android:name=".ControlBluetoothConnection" />
<activity android:name=".Connection" />
<activity
android:name=".KeyboardActivity"
android:screenOrientation="landscape" />
<activity
android:name=".ProfileSettingsActivity"
android:screenOrientation="portrait" />
<activity
android:name=".loginActivity"
android:screenOrientation="portrait" />
<activity
android:name=".buyPremiumActivity"
android:screenOrientation="portrait" />
<activity
android:name=".select_control"
android:screenOrientation="portrait" />
<activity
android:name=".SettingsActivity"
android:screenOrientation="portrait" />
<activity
android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I keep trying anyways.
In your manifest file , inside the application tag put this code
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
/// pass the key generated from your admob which contains ~(APP ID)
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/> //
</application>
just check whether meta-data tag is out of activity tag
if it is like this
<manifest>
<application>
<activity>
<meta-data>
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-4347201915048498~6120388314"/>
</activity>
</application>
</manifest>
this should be changed to this
<manifest>
<application>
<activity>
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-4347201915048498~6120388314"/>
</application>
</manifest>

Missing AdActivity in AndroidManifest.xml

I am having this error
I/Ads (21352): Starting ad request.
I/Ads (21352): SDK version: afma-sdk-a-v15090040.14300000.1
I/Ads (21352): This request is sent from a test device.
W/Ads (21352): Could not find com.google.android.gms.ads.AdActivity, please make sure it is declared in AndroidManifest.xml.
W/Ads (21352): Missing AdActivity with android:configChanges in AndroidManifest.xml. You must have the following declaration within the <application> element: <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
D/skia (21352): Program linking failed.
D/skia (21352): Program linking failed.
I tried to resolve the issue as per mentioned in this missing-adactivity-with-android-configchanges and AdView - Missing adActivity with android:configChanges in AndroidManifest.xml but it having same issue.
in profile/AndroidManifest I have
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="puns.jokes.org.jokespuns">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
in main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="puns.jokes.org.jokespuns">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Jokes and Puns"
android:icon="#mipmap/ic_launcher">
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in #style/LaunchTheme). -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-<app-id>"/>
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
What I am doing wrong here?
I was receiving the same error.
My solution to this problem was to update in the grandle build at the application level.
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms: google-services: 4.2.0'
My AndroidManifest:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-***********~**********"/>
I hope it helps. regards

Cause of Error Message "Error:(27) Tag <manifest> attribute package has invalid type 4."

When trying to build my app, I get the following error message: "Error:(27) Tag <manifest> attribute package has invalid type 4." Any ideas on what is causing this? Here is a copy of my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dummy.tanc">
<application
android:supportsRtl="true"
android:allowBackup="true"
android:fullBackupContent="false"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<activity
android:name="com.google.example.games.tanc.MainActivity"
android:label="#string/title_activity_main"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I think it is because, in your manifest, you've set your package name (line 2) to be
package="com.dummy.tanc"
and in when defining the activity (line 18), you've used
android:name="com.google.example.games.tanc.MainActivity"
Because of this mismatch, the issue could be arising. Change the line 18 to
android:name="com.dummy.tanc.MainActivity"
It means attribute package has type float but not string.
I guess your package name contains only numbers, something like package="1.0".

AdMob still not working

I got a problem regarding Google AdMob:
I try to display a Interstitial, for this I have added the AdActivity, permissions and meta-tags to manifest.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lunation.warface"
android:versionCode="10"
android:versionName="1.4" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:largeHeap="true"
android:theme="#style/AppTheme"
android:windowSoftInputMode="adjustPan|adjustResize" >
<!--This meta-data tag is required to use Google Play Services.-->
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!--Include the AdActivity configChanges and theme. -->
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="#android:style/Theme.Translucent" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="sensorPortrait"
android:windowSoftInputMode="adjustPan|adjustResize" >
<intent-filter>
</intent-filter>
</activity>
<activity
android:name=".SplashScreen"
android:noHistory="true"
android:screenOrientation="sensorPortrait"
android:theme="#style/Theme.Transparent" >
<intent-filter>
<action android:name="android.intent.action.MAIN" >
</action>
<category android:name="android.intent.category.LAUNCHER" >
</category>
</intent-filter>
</activity>
<activity android:name="gallery.FullScreenViewActivity"></activity>
</application>
</manifest>
In MainActivity:
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("xxx/xxx");
AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest);
if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
Logcat:
04-04 15:15:19.397: W/Ads(19752): There was a problem getting an ad response. ErrorCode: 0
04-04 15:15:19.407: I/dalvikvm(19752): Could not find method android.webkit.WebSettings.setMixedContentMode, referenced from method com.google.android.gms.ads.internal.s.g.<init>
04-04 15:15:19.407: W/dalvikvm(19752): VFY: unable to resolve virtual method 3153: Landroid/webkit/WebSettings;.setMixedContentMode (I)V
04-04 15:15:19.407: D/dalvikvm(19752): VFY: replacing opcode 0x6e at 0x004a
04-04 15:15:19.502: W/Ads(19752): Failed to load ad: 0
Besides there is also a compilation error:
Conversion of dalvik format failed with error code 1
I tried about 20 answers, still not working.
I also dont know whether the problem is the unit id, I can change
mInterstitialAd.setAdUnitId("xxx/xxx");
to:
mInterstitialAd.setAdUnitId("xxx");
and I got the same errors.
I use the following external libraries:
android support v4&v7, picasso, ftpclient(commons, httpmime),FAB
Does somebody have a advice?
Greetings
Solution found!
Seems like some features in CyanogenMod blocks AdMob.
Flashed a new version WITHOUT Adaware and blocking Tools.
WORKING NOW :D

Android / Google Plus - Cannot share image from my content provider

I have used this code and can successfully share an image (from my phone's gallery) with text to google+ from my Android app.
However, when I try to post an image from my app's content provider, the image is showing up on my google+ page like this...
...and that is despite the intended image being displayed fine on the google+ app preview screen.
The code I am using to share is:
String message = "My message";
Uri localImageUri = ContentUris.withAppendedId(DbContentProvider.CONTENT_URI_PRODUCTS, mProductId;
PlusShare.Builder builder = new PlusShare.Builder(getActivity());
builder.setText(message);
builder.addStream(localImageUri);
builder.setType("image/jpeg");
Intent shareIntent = builder.getIntent();
startActivityForResult(shareIntent, RC_GOOGLE_PLUS);
...and, like I say, the image is successfully displayed on the final google+ page if the localImageUri value is for a resource in my phone's Gallery - whereas the above placeholder image is shown if I set localImageUri to a uri from my app's own content provider.
So I presume there must be an issue with my content provider, which is defined in my manifest as:
<provider
android:name=".DbContentProvider"
android:authorities="com.example.provider"
android:exported="true"
android:grantUriPermissions="true" />
So, could there be something missing from my manifefst - or even from my searchable.xml file:
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="#string/app_name"
android:hint="#string/search_hint"
android:searchSuggestAuthority="com.example.provider"
android:searchSuggestIntentAction="android.intent.action.VIEW"
android:searchSuggestIntentData="content://com.example.provider/suggest"
android:searchSuggestThreshold="3"
android:includeInGlobalSearch="true"
android:searchSettingsDescription="#string/search_settings_description"
android:queryAfterZeroResults="true"
android:voiceSearchMode="showVoiceSearchButton" >
</searchable>
If not, then what could the problem be?
Update (Following CommonsWare's comment)
Exceptions were indeed thrown by the Google+ library because as well doing a query on the _data column (which existed), the Google+ API was also looking for columns that didn't exist - namely, datetaken, date_added, date_modified.
So I have added these columns to my database table - adding them all as text columns with recent millis values such as '1419379390000' (ref here) but I still get the same placeholder image being displayed on my Google+ page.
So I added some logging code to the query() method of my DbContentProvider class and when google+ does its single-column query for datetaken, the value returned in the cursor is indeed 1419379390000. However, the value returned for the (separate) _data query is null.
I'm not sure why the google API queries the _data column (because I do not need to call it in my code when I retrieve the image from the database in order to show in on the UI - instead, I call...
Uri localImageUri = ContentUris.withAppendedId(DbContentProvider.CONTENT_URI_PRODUCTS, mProductId);
InputStream in = cr.openInputStream(localImageUri);
Bitmap img = BitmapFactory.decodeStream(in);
imageView.setImageBitmap(img);
...but presumably the null in my cursor for the _data value is the problem. Not sure where to start to address this, though??
30-Dec-2014 Update
Here is the LogCat output. So, when I click my g+ button...
12-30 21:45:34.344: D/DbContentProvider(24633): getType(content://com.example.provider/products/1668)
12-30 21:45:34.534: D/DbContentProvider(24633): getType(content://com.example.provider/products/1668)
12-30 21:45:34.544: D/DbContentProvider(24633): openFile(content://com.example.provider/products/1668, r)
12-30 21:45:34.584: D/DbContentProvider(24633): openFile(content://com.example.provider/products/1668, r)
12-30 21:45:34.604: D/DbContentProvider(24633): openFile(content://com.example.provider/products/1668, r)
12-30 21:45:34.604: D/DbContentProvider(24633): openFile(content://com.example.provider/products/1668, r)
12-30 21:45:34.624: D/DbContentProvider(24633): openFile(content://com.example.provider/products/1668, r)
...that brings up the g+ screen for customising the share message (which, I confirm, does include the image from my content provider). So I then click the Share button on the g+ screen and the LogCat output is...
12-30 21:45:57.526: D/DbContentProvider(24633): openFile(content://com.example.provider/products/1668, r)
12-30 21:45:57.576: D/DbContentProvider(24633): getType(content://com.example.provider/products/1668)
12-30 21:45:57.576: D/DbContentProvider(24633): DbContentProvider - query(content://com.example.provider/products/1668)
12-30 21:45:57.576: D/DbContentProvider(24633): - projection: {"datetaken"}
12-30 21:45:57.576: D/DbContentProvider(24633): - selection: null
12-30 21:45:57.576: D/DbContentProvider(24633): - selectionArgs: null
12-30 21:45:57.576: D/DbContentProvider(24633): - sortOrder: null
12-30 21:45:57.576: D/DbContentProvider(24633): SQL (without selectionArgs): SELECT datetaken FROM products WHERE (_id = 1668) LIMIT 1
12-30 21:45:57.596: D/DbContentProvider(24633): returned value: 1419379390000
12-30 21:45:57.596: D/DbContentProvider(24633): cursor count: 1
12-30 21:46:03.642: D/DbContentProvider(24633): getType("content://com.example.provider/products/1668") - returns "vnd.android.cursor.item/vnd.example.elemental"
23-Jan-2015 Update
Here is my manifest in full:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="10"
android:versionName="0.10" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.example.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.permission.C2D_MESSAGE" />
<uses-permission android:name="com.android.vending.BILLING" />
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example" />
</intent-filter>
</receiver>
<service android:name=".GcmIntentService" />
<provider
android:name=".DbContentProvider"
android:authorities="com.example.provider"
android:exported="false"
android:grantUriPermissions="false" >
<grant-uri-permission android:pathPrefix="/products" />
</provider>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="#android:style/Theme.Translucent" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</activity>
<activity
android:name=".SplashActivity"
android:label="#string/app_name"
android:launchMode="singleTop" >
<intent-filter android:label="#string/app_name_short">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login"
android:windowSoftInputMode="stateHidden" >
</activity>
<activity
android:name=".HomeActivity"
android:label="#string/app_name_short"
android:windowSoftInputMode="adjustPan" >
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchResultsActivity" />
</activity>
<activity
android:name=".SearchResultsActivity"
android:label="#string/app_name_short"
android:launchMode="singleTop"
android:parentActivityName=".HomeActivity"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".HomeActivity" />
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchResultsActivity" />
</activity>
<activity
android:name=".SingleShoppingListActivity"
android:label="#string/shopping_list"
android:parentActivityName=".HomeActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".HomeActivity" />
</activity>
<activity
android:name=".SingleProductActivity"
android:label="#string/shopping_list_item"
android:parentActivityName=".HomeActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".HomeActivity" />
</activity>
<activity
android:name=".InfoMenuActivity"
android:label="#string/why_gmo_free"
android:parentActivityName=".HomeActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".HomeActivity" />
</activity>
<activity
android:name=".InfoContentActivity"
android:label="#string/why_gmo_free"
android:parentActivityName=".InfoMenuActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".InfoMenuActivity" />
</activity>
<activity
android:name=".SettingsActivity"
android:label="#string/settings"
android:parentActivityName=".HomeActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".HomeActivity" />
</activity>
<activity
android:name=".TwitterCallbackActivity"
android:label="#string/app_name" >
<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="twitter"
android:scheme="oauth" />
</intent-filter>
</activity>
<activity
android:name=".DummyActivity"
android:label="#string/title_activity_dummy" >
</activity>
<activity
android:name=".SmartSearchResultsActivity"
android:label="#string/app_name_short"
android:parentActivityName=".SearchResultsActivity"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".SearchResultsActivity" />
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchResultsActivity" />
</activity>
<activity
android:name=".WebViewActivity"
android:label="#string/app_name_short"
android:parentActivityName=".HomeActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".HomeActivity" />
</activity>
<activity
android:name=".UpgradeActivity"
android:label="#string/upgrade_to_pro_qm" >
</activity>
</application>
</manifest>
This is an interesting problem. If your ContentProvider is exported (which is not entirely clear in the question -- it seems to be in the first snippet you posted, but not in the full AndroidManifest.xml added later) what you're doing should work. Not sure why it doesn't.
In any case, you can certainly share any image file to the Google+ app by means of a FileProvider:
FileProvider is a special subclass of ContentProvider that facilitates
secure sharing of files associated with an app by creating a
content:// Uri for a file instead of a file:/// Uri.
Therefore, if your image is actually a file under getFilesDir() (very likely) or can be at least moved there, then you can apply this solution.
First you must define the provider in your AndroidManifest.xml file:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.testshare.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/filepaths" />
</provider>
Then this file in res\xml\filepaths.xml:
<?xml version="1.0" encoding="utf-8"?>
<paths>
<files-path name="shared_images" path="shared_images/" />
</paths>
Then, to share an image file, first make sure it's in the path specified above (i.e. shared_images under getFilesDir() -- you don't need the WRITE_EXTERNAL_STORAGE permission to copy if there because this location is inside your own app's private storage area). Then build the share intent as follows:
File file = getImageFileToShare();
Uri fileUri = FileProvider.getUriForFile(this, "com.example.testshare.fileprovider", file);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, fileUri);
intent.setType("image/png");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
(Make sure the authority specified in the getUriForFile() method matches the one in the manifest).
This will produce a content:// Uri (like content://com.example.testshare.fileprovider/shared_images/img1.png that the Google+ app will be able to access, and thus include in the post).

Categories

Resources