I can't add admob code interstitial android - android

hi guys sorry about my english,
I have problem in my application Android , I have code panner in apps it's working! but I don't have code interstitial in application, I tried to enter this code
https://developers.google.com/mobile-ads-sdk/docs/admob/advanced
*add under public class MainActivity extends AbstractContentActivity{
find this problem in eclipse :
Multiple markers at this line
- Cannot override the final method from AbstractActivity
- overrides
com.ex.activity.AbstractActivity.onCreate

If you have control over AbstractActivity, remove the final keyword from onCreate and then you'll be able to extend it properly. Also note that in their example they're using just a plain Activity.
If you can't modify AbstractActivity, look at it's code it must have an extension point (overridable method) which will be called from onCreate.

Related

Android Trucaller SDK needs a argument in getProfile

TruecallerSDK.getInstance().getUserProfile();
The above line is not working in Android Studio. Its the exact line copied from the Truecaller official docs. They that getUserProfile does not take any argument but when i write it like this, it doesn't work.
Please help! It requires a FragmentActivity or a Fragment method.
And i am writing this code in my onCreate in MainActivity

Function unresolved reference in main activity

so I'll try to explain my problem this time without pasting you 400 lines of code.
I have a custom view that im using in my main activity (com.company.app.common.ui.view1), in my main activity it's imported properly as follow
import com.company.app.common.ui.view1
Inside view1 i have a function defined in the constructor
fun updateItems(items: List<Item>){}
Item is an object I have modeled properly and the function has no errors.
But when I try to call it in my main activity using
view1.updateItems(items) I get an unresolved reference on updateItems.
the function is supposedly public by default if im not wrong, can anyone help? Thanks
It looks like you are trying to call the method on class rather than on instance (one way to get an instance is to create it via constructor myView1 = view1(...) and then you can call the method on it myView1.updateItems(items)
Two more points:
No need to post all code, just post snippets (only the code relevant to the issue), replace the non-relevant code with ... and keep the parenthesis
In my answer I assumed (based on what you wrote) that view1 is supposed to be a class/object, it's good practice to capitalize it's name so it does not get confused with instances

What is the meaning of putting class name inside the brackets?

While observing an existing android application, I encountered this line of code:
((StoredVariables)this.getApplication()).getId
Why we are using this? What is the outcome of the code? Does it returns previously stored values from sharedPreference? No documentation found on internet to get an idea about it. Please explain.
You are probably a little newbie in Java also
I'm not sure about what is "this" in this.getApplication() and what the StoredVariable is, since it is not an android class...
But here are recommendations for you:
Look for StoredVariable in your class in imports section. You can find something like import my.project.StoredVariable;
Open the class (I'm 80% sure it will be interface) to see the class (this is already answer to your question)
See getId() method there
To know more about usage of StoredVariables. If this line of code is placed inside class that extends some Activity (e.g. AppCompatActivity, Activity e.t.c.)
Open AndroidManifest.xml and look into <application> tag to find android:name in there. Open class with that name (ctrl + click or cmd + click on class name)
This class is extending Application class (or subclass) and implementing StoredVariables interface, or it is directly StoredVariable class

NullPointerException's on StartActivityForResult, Struggling with SQLite in android i think?

I have one class called Budget.java, within that i start Keypad.java. This was all working fine up until recently when i added a bunch of code to Keypad.java (The added code was to update a row in my SQLite database on the press of a button, all the unrelated methods were working until i tried to implement this). Now using breakpoints i think i've figured out that i get the error message as soon as i try to open the Keypad activity and i don't have a clue what could be the problem.
Maybe it's my misunderstanding of the sqlite open helper? Or perhaps its because i'm using StartActivityForResult?
Any suggestions would be very appreciated! I can upload the logcat if you think that would help.
I uploaded the two little classes to pastebin, you might find it easier to read?
Budget.java ( look for ListItemCommonIntent )
keypad.java
In your Keypad.java, you have the following outside the onCreate:
EditText userAmount=(EditText)this.findViewById(R.id.cost_input);
This wont work because you have to use the setContentView to reference the layout where you want to find the view. And when it initializes userAmount, the object is not available yet (so this is null) .
Try this:
private EditText userAmount;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.keypad);
userAmount=(EditText)findViewById(R.id.cost_input);
MySpinner();
Main();
}

Add Words to Android's UserDictionary

I want to add an entire medical dictionary to my android phone (Moto Droid). I would like to be able to send text messages and have the medical words be in the predictable text.
I've been trying to write a small app that would accomplish this, but everything I try the app crashes on startup. I've never written an app for a mobile platform so that is a first for me. Here is what is not working properly.
public class WordAdd extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
UserDictionary.Words.addWord( this , "newMedicalWord", 1, UserDictionary.Words.LOCALE_TYPE_CURRENT);
}
}
It seems so simple to do, yet I am so stuck. Thanks for any help you can provide.
EDIT: I should mention that I am getting this error for Android 2.1 in the AVD (virtual device).
EDIT 2: User Dictionary is found in the Android API. addWord is a static method. I don't declare UserDictionary because I just use the one static method. It's been ages since I developed anything in Java and this is my first attempt at any mobile development, so I don't know if I am doing something wrong.
Add this to your app's AndroidManifest.xml file outside of the <application> element:
<uses-permission android:name="android.permission.WRITE_USER_DICTIONARY"></uses-permission>
Try setting a breakpoint at the start of your activity and stepping through the code with the debugger. This should help you isolate whether that call is really what is causing the crash, and what the underlying exception is.
mm mm where UserDictionary is defined? maybe you should just
UserDictionary = new UserDictionaryType();
UserDictionary.Words = new WordsType();
OR define in the class just under the class declaration the fallowing :
static UserDictionaryType UserDictionary;
if that's the case it's obvious why your app crashed ... (do it on kernel mode and "Houston we got a problem" you cant access pointer that you didnt allocated memory for even in java which is managed code... )
but again I am not familiar with your code show us where it defined and I would try to help you more ...
EDIT1: even if UserDictionary exists in the API you didn't declare on one...
you should declare somewhwere static UserDictionary ud = new UserDictionary();

Categories

Resources