TrueSDK.getInstance().getUserProfile(), What is the parameter of this method using example - android

When i did try to pass my MainActivity it gives me error. So, tell me what to pass in this method parameter.

TrueSDK.getInstance().getUserProfile() does not require a parameter! you should call it without any paramter.
here is the documentation.

in Kotlin just pass
TruecallerSDK.getInstance().getUserProfile(this)

Related

'get(String!): Any?' is deprecated in Java, is there an alternative?

I've got a line of code like this:
val smsRetrieverStatus = extrasObj?.get(SmsRetriever.EXTRA_STATUS) as Status
But it's now deprecated as shown:
Is there any alternative way of doing this without getting deprecation warnings?
If you read the method documentation here, it says:
This method was deprecated in API level 33. Use the type-safe specific
APIs depending on the type of the item to be retrieved, eg.
getString(java.lang.String)
So, they're telling you to stop using the generic get() method, and instead use a type-specific one -- getString(), getInt(), getLong(), etc.
Update:
If you have a custom class or data type, then you'll need to implement your own logic to serialize that class (maybe use something like Gson). And once you've serialized it into a String, you can then use getString()
You can try another method
val status = extrasObj?.getParcelable(SmsRetriever.EXTRA_STATUS, Status::class.java)
Note that this method is not stable and sometimes throws NPE. So you'd better catch and handle the NPE.

I can't pass the argument while using higher order function

Here you can see that I can't pass that string parameter
I somehow learned how to pass a method in the same class but, when I want to call it from another class, I can't pass the arguments.
Several issues here:
the introduceMyself method accepts a higher-order function, but in its usage it seems that you don't want the method itself, but its result. I'd suggest replacing the getName parameter with name parameter and convert it to a regular string which will be provided externally by an invocation of said method.
In line 6, you have a syntax error. Since you're using an instance - person, you can replace the :: with a . like so: person.myNameIs("michael"). It's not working because :: passes the method itself, which you don't really want. Again, your code implies that you need to pass the result of the method and not the method itself.
Finally, you can pass higher order functions, but you can't pass them "with an argument". You can do one of 3 things:
Invoke the HOF locally and pass the result of the invocation
Pass the HOF and the argument and invoke them wherever it is you need to.
Pass the HOF and let the target pass whatever argument it chooses.

Builder.put can only be called from within the same library group (groupId=androidx.work)

When i am using WorkManager and I'm trying to pass some object to it
Data data = new Data.Builder().put("passstring",object).build();
getting me Builder.put can only be called from within the same library group (groupId=androidx.work) error
You can use workDataOf() method. Just make sure you pass Pairs of data
eg.
workDataOf(Pair("param_name", "data"))
Looks like you should use putString method like this.
Data data = new Data.Builder().putString("passstring",object).build();
Because put method marked with annotation #RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) and not documented here:
https://developer.android.com/reference/androidx/work/Data.Builder

Methods : Make my method with many input variables with out overloading

is there Any Way To Make my Method Take many input variable but with out overloading ... could be my question not clear ... I mean Like That :
if I Have This Method
public void setValues (int val1,int val2 ,String val3){
}
what I want is : use this method with many way
setValues (val1,val2)
OR
setValues (val3)
why I want to do that with out overloading : Because if i have as example 10 variable i want to add many method with overloading but i don't like that ...
is there any way helps me to check variable or skip it in the same method ..
Thanks for help .
You can use varargs future to partially solve your problem http://docs.oracle.com/javase/1.5.0/docs/guide/language/varargs.html
This can be done if you have parameters of a same type.
But it will require that you will pass variables with the same type as a last param. It is not completely what you want, but it is a small workaround.
No there's no way to do that in Java without method overloading. One alternative would be to group those parameters which are related and make them fields of a class. Then the method would take an instance of that class as a parameter, and which ever parameters were optional would then be null.

Android Parameter Passing Method

Which parameter passing method is used in Android? Pass by reference or Pass by Value? Please provide an Android Specific example for the same.
All parameter passing in Java is by value.
Here is a nice article with all the details.
just like a normal Java Application:
Objects are passed by reference,
primitives are passed by value

Categories

Resources