I decided to add admob ad to my project and when creating the onCreate method I get an error - Unresolved reference: setContentView. Although I did everything as in the Google Admob documentation
Help, I'm a biginer in Android Studioenter image description here
In the AdMob Documentation, it is shown for the Activity.
Please check out setContentView details
In your FRAGMENT case, replace "setContentView(R.layout.activity_main)" with any of the below
If Data Binding is being used, then
FragmentHomeBinding.inflate(inflater, container, false)
Otherwise,
inflater.inflate(R.layout.fragment_home, container, false)
Please check Adding a user interface for FRAGMENTS for further details
Related
Question:
How does one define a Gmail API scope for a GoogleSignInOptions.Builder()?
Summary:
I have an Android app written in Kotlin, in which I am attempting to integrate a call to the Gmail API, though can not add the GMAIL_READONLY scope when requesting scopes.
Relevant Information & What I've tried:
From the documentation here:
...to configure Google Sign-In to request users' ID and basic profile information, create a GoogleSignInOptions object with the DEFAULT_SIGN_IN parameter. To request users' email addresses as well, create the GoogleSignInOptions object with the requestEmail option.
If you need to request additional scopes to access Google APIs, specify them with requestScopes.
I have in my application gradle file the Google API client and Gmail service dependencies taken from the Java Gmail Quickstart:
implementation 'com.google.api-client:google-api-client:1.23.0'
implementation 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
implementation 'com.google.apis:google-api-services-gmail:v1-rev83-1.23.0'
And in the corresponding fragment I have a setOnClickListener{} for a button which is to make the API call. Following the steps on the previously linked "Integrating Google Sign-In into Your Android App" page, I have the following code snippet:
view.findViewById<Button>(R.id.google_sign_in_button).setOnClickListener {
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build()
}
I am however having build errors when I attempt to add the Gmail.READONLY scope.
Examples:
Using the following declaration
val gmailScope = Scope(GmailScopes.GMAIL_READONLY)
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(GmailScopes.GMAIL_READONLY)
.build()
gives a Type mismatch error, for which the required type is Scope and GmailScopes.GMAIL_READONLY is of type String. The Gmail Java Quickstart uses a String List for defininf scopes with:
Collections.singletonList(GmailScopes.GMAIL_LABELS);
However integrating this with
.requestScopes(Collections.singletonList(GmailScopes.GMAIL_LABELS))
gives the same type error, naturally with a Mutable List<String> instead of the previous String.
The Scope class as documented on this Google APIs for Android page defines the constructor to be:
Scope(String scopeUri): Creates a new scope with the given URI.
So I attempted an implementation using this class as such:
val gmailScope = Scope(GmailScopes.GMAIL_READONLY)
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(gmailScope)
.build()
and also directly with the URI:
val gmailScope = Scope("https://www.googleapis.com/auth/gmail.readonly")
However this gives an Unresolved refernce: Scope error. I followed the advice from this question but to no avail.
Answer:
The .kt file is missing the Scope class import from android.gms.common.api.
Import line:
import com.google.android.gms.common.api.Scope
I have implemented GCM with Xamarin.ios , I am able to get Device Token and GCM ID , But i am not able to recive Notification sent by Push sharp library . I am seeing log and i am getting below issue.Can this be reason of not receiving notification ?. Also we are new in Xamarin ,It will be hlpful if somebody can help us with podfile.
You have enabled the CloudMessaging service in Developer Console, but it appears as though your Podfile is missing the line: 'pod "Google/CloudMessaging" or you may need to run pod update in your project directory.
You need to add this component and implement it in your AppDelegate There are code examples of how to do so in the Getting Started section.
You need to add this component and implement it in your AppDelegate There are code examples of how to do so in the Getting Started section.
I'm attempting to get HockeyApp to work in my iOS Xamarin Forms app. I installed the iOS HockeyApp component (v4.1.0), and the getting started information for shows the following:
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
var manager = BITHockeyManager.SharedHockeyManager;
manager.Configure("Your_App_Id");
manager.StartManager();
}
When I try this, BITHockeyManager.SharedHockeyManager is null.
I've tried to wrap these lines in HockeyApp.Setup.EnableCustomCrashReporting() and Setup.EnableCustomCrashReporting() as is referenced in this post, but Setup doesn't exist in the namespaces I have.
What am I missing to properly enable HockeyApp in iOS?
Whoo hoo! Figured it out finally! I had the linker options set to link 'All assemblies' because of a suggestion from the New type registrar in Xamarin.iOS 7.2.1, errors MT5210 and MT5211 thread. I was seeing the 'Native linking failed...' error and switching to 'All assemblies' initially fixed it.
Switching to 'Link SDK assemblies only' fixed both problems
I am making an app and I have a button that says Sign in and when you click on the button it is supposed to redirect you to a new page that will have you sign in. When i clicked New>Activity and selected a log in page and clicked finish there was an error that says Cannot Find Symbol Class Login Activity. Heres the location of the error in code:
private void addEmailsToAutoComplete(List<String> emailAddressCollection) {
//Create adapter to tell the AutoCompleteTextView what to show in its dropdown list.
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(LoginActivity.this,
android.R.layout.simple_dropdown_item_1line,
emailAddressCollection);
mEmailView.setAdapter(adapter);
}
Open your SDK Manager (Tools menu > Android), and install Android Support Repository in Extras. After this you may need to click the Sync Project with Gradle Files button in the toolbar.
I'm just starting, and I had the same issue.
I added the login activity using Android Studio's wizard, but I didn't use the default activity name.
When the class was generated, it referenced to "LoginActivity.this", using the default name.
In my case, I just needed to replace the Activity name for the one I've used while creating it.
Example:
new ArrayAdapter( "ActualNameOfLoginActivity" .this...
I have created an iPad storyboard application using the newest version of Monotouch. My first screen is a login screen that I only want to show if the user has not saved his credentials. If credentials are available I want to instead navigate to the UITabBarController that is the second scene. I can't seem to find any documentation on how to do this. I tried creating an instance of the UITabBarController and pushing to it but it does not work.
homeScreen = new HomeTabBarNavigator(this.Handle);
this.NavigationController.PushViewController(homeScreen,true);
HomeTabBarNavigator is a UITabBarController that is already linked to other scenes. I get the following error:
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
I assume I am getting this error because I have not defined any views to the ViewControllers property of my HomeTabBarNavigator. I was hoping that those views were already defined but that does not seem to be the case. Any ideas.
The best solution I could find is to call PerformSegue on the controller. Here is some example code:
this.PerformSegue("LoginSegue",this);
The controller that is loaded is the LoginController, and LoginSegue is a Segue that points to the HomeTabBarNavigator. While it is not perfect, the applications loaded the tabbar properly.
I used this stackoverlflow iOS question as the basis for my solution.