Facebook SDK button in android studio - android

I am trying to add a facebook login to my app, in addition to my custom log in.
I added facebook sdk as a module but when I try to add the Facebook Connect button I get an error.
Error:
Rendering Problems The following classes could not be instantiated:
- com.facebook.widget.LoginButton (Open Class, Show Exception)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE Exception Details android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F040001.
Code:
<com.facebook.widget.LoginButton
android:id="#+id/authButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="45dp" />

First it is possible problem of the Eclipse, you just need to rester environment. To see if help.
Secondary, try to use this code snippet to solve problem.
if (isInEditMode())
{
//do something else, as getResources() is not valid.
} else {
//you can use getResources()
String mystring = getResources().getString(R.string.mystring);
}

Related

Xamarin how to solve accessibility content labeling problem?

When i upload a relese to Google Play Console, after internal testing y have a warning (Accessibility => Content labeling) associated to this component.
<ImageButton .../>
Here the recomendation is use android:contentDescription
Then i add xmlns:android="http://schemas.android.com/apk/res/android"
and:
<ImageButton android:contentDescription="bla bla" .../>
But i get an error: The property contentDescription was not found in type ImageButton.
I try to use xct:SemanticEffect.Description and i have not compiler error but in Google Play Console i still see the warning.
More Information:
Full component code:
<ImageButton BackgroundColor="Transparent" Margin="5" xct:SemanticEffect.Description="abrir menú" Clicked="OnBackButtonClicked" >
<ImageButton.Source>
<FontImageSource FontFamily="FAL" Glyph="" Color="{StaticResource Gray3}" Size="25"/>
</ImageButton.Source>
</ImageButton>
Google Play Console - Pre-launch report details - Accesibility tab
Content labeling warning for this component
As already pointed out, you cannot add android:contentDescription="bla bla" directly to the ImageButton one is from the Android platform, the latter is on the Xamarin.Forms level.
If you use the Xamarin Community Toolkit and apply the SemanticEffect.Description="bla bla" that should translate into the contentDescription on Android. If that is not the case, I would be curious to know what the exact warning is that you get after applying it.

show VR tour in android

I want to show VR tour like this http://alfavr.ir/alfavr.ir/to/park.html in my Android app.
how can I do that?
I tried to display with web view because the file format is Html but did not work.
You can try with VRPanormaView which is included in the Google VR SDK. This is an example from https://developers.google.com/vr/develop/android/vrview:
<com.google.vr.sdk.widgets.pano.VrPanoramaView
android:id="#+id/pano_view"
android:layout_margin="5dip"
android:layout_width="match_parent"
android:scrollbars="#null"
android:layout_height="250dip" />
Inside the Activity, the primary method is VrPanoramaView.loadImageFromBitmap(). Call it with a standard Android Bitmap object and an optional VrPanoramaView.Options object. The latter is used to configure the format of the image. The Activity also implements a VrPanoramaEventListener which receives events when the load operation succeeds or fails.
Adding this line make It work.
webView.getSettings().setJavaScriptEnabled(true);

Facebook Android SDK 4.5 LikeView not working

I am trying to integrate latest facebook android sdk(v 4.5) Like button. This is what I have put in my facebook_layout.xml
<com.facebook.share.widget.LikeView
android:layout_marginTop="30dp"
android:id="#+id/like_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
</com.facebook.share.widget.LikeView>
And I have a fragment where I am putting this like view onCreate method to
initialize the view
LikeView likeView = (LikeView)facebookview.findViewById(R.id.like_view);
likeView.setEnabled(true);
likeView.setLikeViewStyle(LikeView.Style.BOX_COUNT);
likeView.setObjectIdAndType(
"https://www.facebook.com/FacebookDevelopers",
LikeView.ObjectType.PAGE);
Apart from this I have also put my app id in AndroidManifest.xml as mentioned here
But I am still not able to get the like to work. When I Click on the like button it just opens up a black facebook activity and for few seconds and closes it, and there are no likes happening on this page or the same page i have created for testing.
I have resolved this issue by adding my facebook user as a Tester/Developer to my facebook android App.
Reference: https://developers.facebook.com/docs/apps/security
Note: you can set the error listener to the object of LikeView for the better understanding of what error you are getting.
likeView.setOnErrorListener(new LikeView.OnErrorListener() {
#Override
public void onError(FacebookException e) {
Log.e(TAG, e.getMessage(), e);
}
});

InMobi SDK in Android Studio shows error for IMBanner

I am integrating Inmobi SDK for ads in my android application. I have setup my inmobi account and have the application id from there. Below is the XML is use to setup the ad
<com.inmobi.monetization.IMBanner
android:layout_width="320dp"
android:layout_height="50dp"
android:id="#+id/banner"
adSize="15"
appId="xxxxxxxxxx"
/>
And of course i have replaced the XXXXX with my application id from the property in my Inmobi account. The first problem i observed was that appId is not being identified as a valid attribute.
Secondly if i try and do a findViewById in my activity I always get a null reference back.
What am i missing in the implementation here?
This was a very silly mistake. In Android Studio there were multiple layout files for the same activity and I was adding the AdView only to one of them.

Span error when sending email from android device within the app [duplicate]

I have the following layout (virtually empty):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/set_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="content desc"
android:orientation="vertical" >
<TextView android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a TextView" />
</LinearLayout>
The Activity class contains the following:
public class TestActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
}
}
When I run this on my mobile device I get the following error:
SpannableStringBuilder
SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
I have tried this with and without the TextView and the error still remains, I must be doing something fundamentally wrong for such a basic layout to cause this.
Does anyone have any ideas on how I can get this to load without the error?
I have run into the same error entries in LogCat. In my case it's caused by the 3rd party keyboard I am using. When I change it back to Android keyboard, the error entry does not show up any more.
Because the error you're getting is not related to an EditText, then it's not related to your keyboard.
The errors you are getting are not a result of your code; you probably are testing on a Samsung device that has Samsung's TouchWiz.
I had the same errors, then I tested on a Nexus S (also by Samsung, but pure Android OS without TouchWiz) and I didn't get this error.
So, in your case, just ignore these errors while testing on a device! :)
Looking at your code, I'm not sure why you're getting that error, but I had this same error but with EditText fields.
Changing android:inputType="text" (or any of the other inputType text variations) to android:inputType="textNoSuggestions" (or android:inputType="textEmailAddress|textNoSuggestions", for example) fixed it for me.
You can also set this in Code with something like
mInputField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
Looks like Android assumes by default that EditText fields will have suggestions. When they don't, it errors. Not 100% confident in that explanation, but the above mentioned changes fixed it for me.
http://developer.android.com/reference/android/text/Spanned.html#SPAN_EXCLUSIVE_EXCLUSIVE
Hope this helps!
On your android phone go to:
settings -> application manager -> all -> samsung keyboard and then click on "clear cache"
(delete all data collected by this application).
Try using the default Android keyboard it will disappear
Make clear you have pass a value in your MainAcitivity for the following methods onCreateOptionsMenu and onCreate
In some cases, the developer deletes the "return super.onCreateOptionsMenu(menu)" statement and changed to "return true".
This worked for me...on every device
<EditText
android:maxLines="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="15sp"
android:layout_centerVertical="true"
android:textColor="#000"
android:id="#+id/input_search"
android:background="#null"
android:inputType="text"
android:hint="Enter Address, City or Zip Code"
android:imeOptions="actionSearch"
/>
In Java code:
mSearchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
#Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
if(actionId == EditorInfo.IME_ACTION_SEARCH
|| actionId == EditorInfo.IME_ACTION_DONE
|| keyEvent.getAction() == KeyEvent.ACTION_DOWN
|| keyEvent.getAction() == KeyEvent.KEYCODE_ENTER){
//execute our method for searching
}
return false;
}
});
I had the same warning and found that removing an unused #id got rid of the warning. For me it was obvious as the #id was associated with a growing list of textViews linked to a database, so there was a warning for each entry.
Masood Moshref is right, this error occur because the option menu of Menu is not well prepared by lacking "return super.onCreateOptionsMenu(menu)" in onCreate() method.
To try to debug this error, first go to your android terminal / console and execute this command:
ps | grep THE_ERROR_PID_YOU_GET_(IT_IS_A_NUMBER)
then if the output comes out as your app... it is your app causing the error. Try to look for empty Strings that you pass into the layout.
I had this exact same problem and it was my fault as I was passing an empty String into my layout. After changing the "" to " " this error went away.
If you don't get your app from the console output, then it is something else causing it (probably, as others said, the android keyboard)
I have faced the same issue. I almost wasted almost couple of weeks to resolved this issue.
Finally I had on doubt on myself and tried to create another project by copy and paste some startup files like SplashScreen & LoginScreen.
But with the same code still i was getting SPAN_EXCLUSIVE_EXCLUSIVE.
Then i have removed the handler code from splash screen and tried again and Wow its working.
I am not getting SPAN_EXCLUSIVE_EXCLUSIVE issue in logcat.
I wondering, why it is? till the time did not get any other solution but by removing handler from splash screen it is working.
Try and update here if it is resolved or not.
Check if you have any element such as button or text view duplicated (copied twice) in the screen where this encounters. I did this unnoticed and had to face the same issue.
I ran into this problem too when I copied some text from the Internet. My solution is to trim the text/remove formatting before doing any further processing.
I had the same problem but with a listView.... i solved it because i was using a wrong R.id.listView that list View needed to have a value, in my case it was strings that i saved on listView2... so the right code was R.id.listView2
I had the same problem then i fixed it by following code!
text = (EditText)findViewById(R.id.TextVoiceeditText);
text.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
this error also occurs due to changed API URL. try hitting the URL you are using in postman and c if it's working properly.
rechecking the APIs solved my problem
try avoiding use of view in xml design.I too had the same probem but when I removed the view. its worked perfectly.
like example:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:inputType="number"
android:textColor="#fff" />
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#f9d7db" />
also check and try changing by trial and error android:inputType="number" to android:inputType="text" or better not using it if not required .Sometimes keyboard stuck and gets error in some of the devices.
In my case, the EditText fields with inputType as text / textCapCharacters were casing this error. I noticed this in my logcat whenever I used backspace to completely remove the text typed in any of these fields.
The solution which worked for me was to change the inputType of those fields to textNoSuggestions as this was the most suited type and didn't give me any unwanted errors anymore.
in my case i click on recent apps shortcut on my cell phone and close all apps. This solution always work for me, because this error not related to code.
**DONT PUT SET TEXT IN TEXT WATCHER**etSearch.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable) {
visibleResultList = false
if (s.toString().length != 0) {
getSearchSuggetion(no_of_rec, 0, s.toString())
} else {
// etSearch.setText("")
}
Log.e("text_change","============"+s.toString())
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
}
})
To solve this problem just add android:usesCleartextTraffic="true" in your AndroidManifest.xml file which is at ..\app\src\main\AndroidManifest.xml just like bellow...

Categories

Resources