Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 days ago.
Improve this question
My Crashlytics services often notify me about this error. I tried to understand the reason, but I can' reproduce it. I think Jetpack-Compose is quite new and some devices will get errors with it. My navController object provided by local composition.
val navController = localAppNavController.current
java.lang.NullPointerException:
androidx.navigation.NavController.navigate(NavController.kt:1652)
androidx.navigation.NavController.navigate(NavController.kt:1984)
androidx.navigation.NavController.navigate$default(NavController.kt:1979)
It said that the _graph object is null
LaunchedEffect(key1 = contactAction){
when (contactAction) {
is ContactAction.EditContactAction -> {
navController.navigate(Screen.EditContact.withOptionalArgs(mapOf(Constants.RAW_CONTACT_ID to contactAction.editContactId.toString())))
}
is ContactAction.ViewContactAction -> {
navController.navigate(Screen.ContactDetail.withArgs(contactAction.viewContactId.toString()))
}
is ContactAction.CreateContactAction -> {
val phone = contactAction.data[Constants.PHONE]?:""
navController.navigate(Screen.EditContact.withOptionalArgs(mapOf(Constants.PHONE to phone)))
}}
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 12 months ago.
Improve this question
Implementing BaseOnSliderTouchListener's onStartTrackingTouch and onStopTrackingTouch (documentation) give the lint the following error message :
Error: BaseOnSliderTouchListener.onStartTrackingTouch can only be called from within the same library group (referenced groupId=com.google.android.material from groupId=your-group-id) [RestrictedApi]
I had the same issue. The workaround with #SuppressLint("RestrictedApi") works.
The root cause is that the BaseOnSliderTouchListener class has a library restricted scope and the methods exposed there are not overridden in OnSliderTouchListener.
The issue is tracked in the material-components library here: https://github.com/material-components/material-components-android/issues/2493
It has been fixed in the 1.6.0-alpha02 release of material-components.
Temporary solution:
Add #SuppressLint("RestrictedApi") annotation.
Example:
slider.addOnSliderTouchListener(object : Slider.OnSliderTouchListener {
#SuppressLint("RestrictedApi")
override fun onStartTrackingTouch(slider: Slider) {
[...]
}
#SuppressLint("RestrictedApi")
override fun onStopTrackingTouch(slider: Slider) {
[...]
}
})
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
Im a beginner in Android Studio and have a school project where I have to create an login screen with password and username. When trying to follow some instructions online I get an error even though I have done the same as the instructor. Can you see what I have done wrong?
Example image
Your code is in Kotlin while the video you linked uses Java, so the error indicates that the onClickListener is not following Kotlin syntax properly.
The equivalent in Kotlin is:
logIn.setOnClickListener {
// Do some work here
}
or
logIn.setOnClickListener(object : View.OnClickListener {
override fun onClick(view: View?) {
// Do some work here
}
})
Both will behave similarly. See alternative ways here.
// declare
private lateinit var logIn: Button
// cast
logIn = findViewById(R.id.logIn)
// execute the func you want
logIn.setOnClickListener {
executeLogInApi()
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I want to disable the editText once timer is finished.
Have a look on the following code:
val CountDownTimer=object: CountDownTimer(10000,1000){
override fun onTick(millisUntilFinished: Long) {
txtTimer.setText(""+millisUntilFinished/1000)
}
override fun onFinish() {
Toast.makeText(this#Play_Area,"time up!",Toast.LENGTH_SHORT).show()
etResponse.isEnabled(false)
}
}
Here etResponse is EditText and when i make #isEnables(false) it is showing following error:
Too many arguments for public open fun isEnabled(): Boolean defined in android.widget.EditText
Please Help How to resolve it
You are using the wrong function.
editText.isEnabled() is used to return the enabled state only and it doesn't take an argument so you can call it like that
val state: Boolean = editText.isEnabled()
instead, you should use editText.isEnabled = true because the property is mutable
editText.isEnabled = false
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm trying to save a user in the repository with a method, when I set the document id as the current user id logged in it gives me this error
user.getUid can only be called from within the same library group (groupId=com.google.firebase)
class FirebaseRepository {
var db = FirebaseFirestore.getInstance()
var auth = FirebaseAuth.getInstance()
var user = auth.currentUser
fun saveUser(user: User): Task<Void>{
var documentReference = db.collection("users").document(user.uid).set(user)
}
}
But when I do set the variable var user = auth.currentUser inside the method works.
Question: What's going on there? What am I missing?
Solution: I didn't notice there were 2 user variables (Class variable and method variable), I was using the method variable instead the auth variable.
Solution: I didn't notice there were 2 user variables (Class variable and method variable), I was using the method variable instead the auth variable.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I want to get read and write rights on the external storage. Therefore I need to give an activity as parameter.
In the Android tutorial and on Stackoverflow the common answer is to use the keyword. I use this https://github.com/tbruyelle/RxPermissions as I read that it is commonly used to make things easier.
this
or
myActivity.this
and on fragment
getActivity()
none of these seem to work and I get can't resolve Activity. Or in the Debug that he cannot cast the activity to fragment
Here is my Class:
public class WebViewActivity extends Activity {
...
...
private void grantPermissions() {
new RxPermissions(WebViewActivity)
.request(Manifest.permission_group.STORAGE) // ask single or multiple permission once
.subscribe( new Consumer<Boolean>() {
#Override
public void accept(Boolean granted) throws Exception {
if (granted) {
// All requested permissions are granted
} else {
// At least one permission is denied
}
}
} );
}
}
How can I parse my activity, am I missing a step?
Thanks for help
Found the solution. I had to clear my cashe.... that was the only reason it was not working.
Instead of
new RxPermissions(WebViewActivity)
You need to use:
new RxPermissions(this)