last day (16 days later) » 

3:20 PM
1
Q: android studio: Attempt to invoke virtual method on a null object reference, While opening activity, to perform an event for 2 every mins

jeevan kotianpackage com.example.pinkconnect; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import android.Manifest; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import and...

 
@Rafsanjani That won't work because he is calling asynchronous calls
Please post your database structure
 
@Ashish, sir, mine is firebase databse jsfiddle.net/Manoj07/xz1o0e9r and heres my database structure
@Rafsanjani Sir, what u said, i did i initialized strings as empty, now its working properly. But messages are not sending for every 2 mins, its sending only once
 
@jeevankotian problem with above code is that Firebase provide asynchronous calls. Till you get your data from database. It will show null to other process.
 
@Ashish sir, How to do that?
 
hey there ?
 
3:22 PM
Hisir
Sir... i did that i mean i initialized strings as empty and then it worked. But the problem is, on shaking the device for 3 times, device should send sms for those 5 contacts repeatedly for every 2 minutes, till i enter the pin and if the pin is correct, then the message sending should stop. How to do that Sir?
 
ohh sorry
let me help you 10 minute
 
OK sir, i'll be waiting for u
 
ok
i am free now
 
yes sir...
 
so can you explain what you want to do
 
3:35 PM
Sir..., on shaking the device for 3 times, device should send sms for those 5 contacts repeatedly for every 2 minutes, till i enter the pin and if the pin is correct, then the message sending should stop. How to do that Sir?
 
ok
can you please provide me sensor for shaking ?
 
shall i upload the whole code in codeshare.io sir?
 
ok
don't call me sir
i am kid
 
ok bro...
jsfiddle.net/Manoj07/67pgdfyb actually codeshare is running on over capacity so i uploaded the code in html section of sfiddle bro...
 
counter = 0;
final SmsManager smsManager = SmsManager.getDefault();
do{
/* //https://www.latlong.net/c/?lat=0.000000&long=0.000000
//http://maps.google.com/maps?q=24.197611,120.780512*/
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 2 mins
for(int m=0;m<5;m++){
smsManager.sendTextMessage(phoneNo.get(m), null, "Hey It's an emergency at this location"+"http://maps.google.com/maps?q="+latitude.toString()+","+longitude.toString(), null, null);
}
}
}, 120000);
so this is your main code right ?
on 3 time shaking
 
3:45 PM
yes sir
bro... and also
 
Please provide me database structure
so i'll generate proper code
your the perfect person who can help me back
 
public void stop(View view){
pin1=t5.getText().toString();
} here on click of stop button, the sending of message should stop
        if (counter >= 3) {
            counter = 0;
            final SmsManager smsManager = SmsManager.getDefault();
            do{
                    /* //latlong.net/c/?lat=0.000000&long=0.000000
                    //maps.google.com/maps?q=24.197611,120.780512*/
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        //Do something after 2 mins
                        for(int m=0;m<5;m++){
        if (counter >= 3) {
            counter = 0;
            final SmsManager smsManager = SmsManager.getDefault();
            do{
                    /* //latlong.net/c/?lat=0.000000&long=0.000000
                    //maps.google.com/maps?q=24.197611,120.780512*/
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        //Do something after 2 mins
                        for(int m=0;m<5;m++){
//get pin
public void stop(View view){
    pin1=t5.getText().toString();
}
jsfiddle.net/Manoj07/xz1o0e9r json database
 
give me 5 minute to generate proper code
 
ok sir...
 
4:09 PM
if (counter >= 3) {
pinn = FirebaseDatabase.getInstance().getReference("7");
pinn.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
pin= (String) dataSnapshot.child("pin").getValue(String.class);
GenericTypeIndicator<ArrayList<String>> t = new GenericTypeIndicator<ArrayList<String>>() {};
ArrayList<String> phone = dataSnapshot.child("phone").getValue(t);
Toast.makeText(HomeActivity.this,"pin is "+pin,Toast.LENGTH_LONG).show();
there ?
this can work properly
 
yes sir, ill check this...
 
let me explain code first
according to above code you will shake device 3 times
then it will take data from firebase
 
ok bro...
 
so
 
Oh nice...
 
4:20 PM
so is it working ?
i want one help from you
 
bro... but the message is delivering only once its not sending repeatedly after every 2 minutes
 
so code working properly ?
then we will work on it
 
and i should stop also if i enter the right PIN
 
if you enter right pin it needs to be stop right ?
then you can't do that
 
yes... i mean the pin here with respect to our db is "123"
 
4:25 PM
something like this easily
because to retrieve data from edittext you need to fire event or textwatcher
 
help me broh... i dont know that
 
just need to research some stuff
 
ok bro...
 
cause your data most likely asynchronous
 
ok then?
how to achieve bro...
 
4:32 PM
i'll try tonight
as much i can do
and notify you tomorrow morning in chat
ok ?
 
OK bro... thank you
will be waiting for ur solution bro
 

  last day (16 days later) »