Creating a Facebook Like button on Android - java

I'm trying to provide a Facebook Like button in my Android app and am having problems. I think that I have everything set up properly:
I'm calling FacebookSdk.sdkInitialize(getApplicationContext());
I've added a LikeView into my activity
I've created an app id using the appropriate key hashes
I've added the following into the manifest inside the application tag:
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="#string/app_name" />
<provider android:authorities="com.facebook.app.FacebookContentProvider000000000099893"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
Where 000000000099893 is my application id (I've zeroed out most of it)
My app is crashing in Facebook's Utility.java class on the line:
FetchedAppSettings settings = fetchedAppSettings.get(applicationId);
Actually it crashes within the HashMap code with a null pointer
This leads me to believe that something is going wrong with my application id. What else should I be looking at?

Okay, after going through all of the code in the SDK and some of the samples I finally figured out what was going on. It seems that I need to add
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/app_id"/>
<meta-data android:name="com.facebook.sdk.ApplicationName"
android:value="#string/facebook_app_name" />
into the manifest.
I just downloaded the SDK today - it says that the version is 4.2.0 but the instructions on the Facebook site do not mention these manifest changes.
Disappointed.

Related

Google Play Services Library Error in OneSignal, why?

i did add OneSignal based on the documentation in my application.
Everything works for me.
However, I can't send notifications to some devices because it says: Google Play Services Library Error (image included)
What I've already tried:
I created a new project in OneSignal (new app id)
the AndroidManifest.xml file contains:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<meta-data android:name="com.onesignal.NotificationOpened.DEFAULT" android:value="DISABLE" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
I don't know what to do now.... :(
Google Play Services Library Error
UPDATE:
only appears on some devices, on first start-up.
Error message:
E / OneSignal: Error Getting FCM Tokenjava.io.IOException: AUTHENTICATION_FAILED
If you reopen the application, the error will disappear.
Try removing and recompiling the application

How to open installed android application via browser in android?

I want to make my app to get opened when user enters particular url in the browser like chrome or internet.For this i have referred and googled about this topic what i noticed is similar and i have used in my manifest file but still doesnt work.
i have referred below links for my issue
Launching custom Android application from Android browser / Chrome
Launch custom android application from android browser
How to open android application when an URL is clicked in the browser
Intercepting links from the browser to open my Android app
All this have same answer but when i use this it has no effect,when i type url www.myurl.co.gdf or http://www.myurl.co.gdf it doesnt prompt the user it opens in browser itself instead of opening myapp or showing choose dialog box
the code i have used in manifest file is as follows
<application
android:icon="#drawable/logo"
android:label="#string/app" >
<activity
android:name="com.app.secondActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/service"
android:screenOrientation="portrait"
android:theme="#style/aa_theme" >
<intent-filter android:label="#string/app" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data
android:host="www.myurl.co.gdf"
android:pathPrefix="/"
android:scheme="http" >
</data>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.VIEW" />
</intent-filter>
</activity>
<activity
android:name="com.app.firstActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/activity_title"
android:screenOrientation="portrait"
android:theme="#style/aa_theme" />
</application>
If this works fine for others why not for me?
Note:i have changed to above code only in manifest and i have not changed or added any thing extra in .java files or anyother files.
For this to work should i make any device setting changes or should i add Uri intentUri = getIntent().getData(); in .java file (should use then why?)or should i type differently in browser or have i used intentfilter in wrong activity or is there anything i am missing?
one more thing i am using some cordova plugins to this app, i dont think this has to do with opening an app.
I am very new to android please give me some ideas regarding this..
The issue isn't with your code- it is with your testing strategy.
Typing a URL in a browser does not typically start an Intent, and thus Android doesn't check to see if any other apps can handle the URL. When a user types a link into Chrome, for example, Chrome assumes that the user wants to continue using Chrome and will handle browsing to the URL itself.
Instead, you need to create an intent containing your URL to test if Android will handle deep links to your application correctly.
The easiest way to do so is via the following ADB command:
adb shell am start
-W -a android.intent.action.VIEW
-d http://www.myurl.co.gdf/

No activity found to handle Intent android.intent.action.REQUEST_TANGO_PERMISSION (has extras)

I'm new to Project Tango and for now I'm trying to run the demo apps provided but I keep on bumping into this error message in both the motion tracking and area learning demo projects because I can't see that action be declared in the manifest file. I know this error complains about either the activity not being declared in the manifest but it is there. Do I need to have anything else installed on the device so this line doesn't make the app crash?
11-04 13:04:21.789: E/AndroidRuntime(2867):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.projecttango.motiontrackingjava/com.projecttango.motiontrackingjava.StartActivity}:
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=android.intent.action.REQUEST_TANGO_PERMISSION (has
extras) }
This is how StartActivity is being declared on the manifest:
<activity
android:name=".StartActivity"
android:screenOrientation="landscape"
android:icon="#drawable/ic_launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Everything you pasted in is correct. The issue seems to be an incorrect version of the TangoCore service. Please try to update your software via OTA.
Edit for more information :
The activity that is missing is a service that handles permissions needed by the Tango service, named Permission Manager. After updating ,via Settings -> About tablet -> System updates, you should have a this new application on your device. If you don't have this application you will not be able to run any Tango applications, as they all prompt the user for permission to run.
The new permissions are for Motion Tracking, ADF saving/loading, and ADF import/export.
More information can be found at the following link. Cheers!
https://developers.google.com/project-tango/apis/java/java-user-permissions
It might be worth noting that you can get into a state where one app will surface this message, but another won't. The solution is the same (OTA update).
I think the case where an app has been deployed, and run previously, then you wipe the machine (and don't get all updates), the previous apps might still run in debug, whereas any new ones one.
Either way, OTA update every time.

always start app from root activity

I have an activity for handling deeplink which is a browsable activity
suppose user clicks a link on another app and my browsable activity handles that intent
and start the app, then user minimise the app after use by pressing back button
if user reopen my app from running apps my browsable activity gets started instead of launcher activity
so my question is how can i start my app from launcher activity instead of browsable if user launches my app from running apps
Quora uses the same procedure, you can test by clicking a link of Quora on any other app
manifest of browsable activity
<activity android:name="com.example.android.deeplink"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:host="com.example"
android:scheme="test" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
class code for handling intent data
Uri link = getIntent().getData();
how can i start my app from launcher activity instead of browsable if user launches my app from running apps
There is more then one approach to achieve this goal,
I believe that the best and simplest way would be to add to your "browsable activity" an Activity flag:
android:excludeFromRecents="true"
settings this flag - will make sure that this activity will simply won't be shown in the recent tasks in the first place.
more info in the documentation - http://developer.android.com/guide/topics/manifest/activity-element.html#exclude

Android NFC intent not being "called"

I have an intent filter set up so that when ever any NFC tech is discovered it calls my activity. This works great when testing with my nexus 7, however when I tried it with my nexus 4 its not working. It makes the noise as if the tag was discovered but there is no app to handle it.
The intent is as fallows.
<activity
android:name=".NfcScanned"
android:label="#string/title_activity_nfc_scanned" >
<!-- Add a technology filter -->
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="#xml/filter_nfc"
/>
Now I could post everything that is in my activity that handles the card scanning however it doesn't get that far, and it works perfectly with another device.
As far as logcat I'm getting this somewhat intriguing error
01-23 00:16:02.343: E/BrcmNfcJni(894): nativeNfcTag_doDisconnect: tag already deactivated
Nexus 4 has a Broadcom NFC chip which does not support your NXP proprietary tag type.
On the other hand, NXP's NFC chip in the Nexus 7 does support the NXP proprietary tag reading.
Cf What NFC tags does the Nexus 7 Support? (2012)

Categories