• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

java.lang.ArrayIndexOutOfBoundsException: length=0; index=0

I am facing some issue in my code, can anyone please help me on this, please find the below crash which i am getting,

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0

at com.***.in.***.onRequestPermissionsResult(***.java:476)

at android.app.Activity.requestPermissions(Activity.java:4290)

at com.***.in.***.startGeofence(***.java:450)

at com.***.in.***.FunctionCall(***.java:332)

at com.***.in.***.LoadConstants(***.java:238)

at com.***.in.***.access$100(***.java:75)

at com.***.in.***$5$1.run(***.java:267)

at android.os.Handler.handleCallback(Handler.java:754)

at android.os.Handler.dispatchMessage(Handler.java:95)

at android.os.Looper.loop(Looper.java:163)

at android.app.ActivityThread.main(ActivityThread.java:6393)

at java.lang.reflect.Method.invoke(Method.java)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)


Please find my code where the crash is happening,

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(
new String[]{
Manifest.permission.ACCESS_FINE_LOCATION
},
4500);
}

@override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if(requestCode != RESULT_CANCELED) {
if (requestCode == 4500) {
***(grantResults[0] == PackageManager.PERMISSION_GRANTED); - #Crash in this line#
} else {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}

Note: This crash is not happening in all devices, only some devices like (ViVo, Redmi, Oppo) - that too specific with specific devices and OS this crash occurs.

Creating a new Battery Update Service app

So im buikding a app that doesnt require root access and gentky searches updates for your model(s) battery so not only your keeping your OS up-to-date but as well keep your battery up-to-date.

This process will take approximately up to 30 mins to find the correct update for your specific android version, model and battery specs and install them in the battery(s) main power boared, it works the same way as a "Pandora's Battery for the PSP" but this is tokeep tge bosrd updated so it can save your battery and force it to output less power even if Power Saving is off.

The point of this app is to force the battery to use the lowest power output without affecting system performance, and with our database we can safely update your batteies binary code by searching the right binary configuration for your specific device, and itll onky update after your system gets a full restart!

Any feedback about this idea?

Help Earphone mic volume is very low in my phone. Any fixes?

Its Lenovo Z2 Plus. It used to work well before. Now, the issue is, people on the other end of phone call are not able to hear me properly while I'm using earphone plus voice recording through earphone mic results in too feeble sound. I've tried this with several earphones. I am using custom ROM AEX now. I think after I have changed to this rom, the mic problem has started. I prefer not to change rom again and again, for I have to spend more time adjusting settings and installing apps and login into all of them, also apps like GPay, Phone Pe may not work. Any solutions for this?

Spots on my screen?

Hey guys! So, I dropped my phone of the floor a while back, and the screen is cracked. At the start, the only issue was the cracks. Over time, however, yellow spots on certain parts of the screen, and yellow streaks along the cracks have formed. Two of the dots are like a purple-y color. Should I be worried?

Help Displaying contact organisation when someone calls

Hi,

My S6 used for work only displays the contact name when someone calls, is it possible to also display organisation and job title? This seems like a really silly thing not to show, I have several thousand work contacts and this information would help me figure out who is calling if I don't recognise the name.

I have done some searching for this but all the strings I've searched for just bring up how to change which contacts are displayed in the contacts list :/

Thanks

Help (Galaxy J2) "Settings keeps stopping." when trying to change language priority in Language settings.

Hi there. I've got a family member who's having problems switching the language priority in the settings between English and Spanish. I've tried many different things like clearing the RAM, uninstalling excess apps, taking out the SD card, and resetting the phone settings (except for factory reset) and nothing seems to work. By switching the number 1. language from English to Spanish then selecting Done, Settings will simply stop working every time. I'm trying to avoid a factory reset as I've set the user up with a work around. Not sure what I need to do at this point. I am somewhat inexperienced with Android OS as I just haven't put time aside to learn it.

Any suggestions and advice will be greatly appreciated on my end.

Thanks in advance!

Help Samsung galaxy tab A 10.5'' 2018 major bug

Hey so I recently got a software update on my samsung galaxy tab A 10.5'' 2018 (the version without the SIM card slot) and I noticed that in Device Maintenance > Battery > Advanced Settings there is an option called "Protect Battery" and it says it stops charging the device when it reaches 85% to extend the battery life, but for some reason when I enable this option it keeps charging past 85%. I tried restarting, disabling the feature and enabling it again, letting the tablet charge completely, restarting the tablet while the charger is connected but nothing worked, it keeps charging even after it reaches 85%. Also, when I made this post the samsung galaxy tab A 10.5 was not available in the drop-down menu which is also kind of weird (perhaps it's a less known tablet?)
I appreciate any help with this.

Missing Labels

Recently I created a home screen folder to contain web pages and apps that have much in common with an upcoming vacation in a city I plan to visit. What I've done is first choose the "add to Home screen" option, add a label or go with the default title to these pages and apps, before adding them to my home screen. Then I drag the result to my created folder. I've built quite a selection of these "subfolders" but have noticed lately that these titles or labels have disappeared, leaving either icons with the Google "G" or other initials pertinent to the content within. How do I get these names, titles or labels back please?

Are chronological notifications possible?

Ugh, I want to scream at my Android phone (Moto Z Force). Again, it happened where I have my phone set to vibrate, and as a result I can't tell which app sent a notification, so I go to look at my notifications, I can see things that happened over the past few days on different apps, and all it shows me on Facebook Messenger as a notification is that someone sent me a sticker yesterday, but in actuality, someone had just sent me an important job-related message that I only found out about after going to Facebook on my desktop computer.

Can someone explain the advantage to non-Chronological notifications on Android? Please? I may not agree with the logic, but if there's at least SOME sort of logic behind it, it would make me less frustrated.

Thanks.

  • Locked
Help Help with Lucky Patcher

How do I prevent Google Play Store from stopping every five seconds when I have "Proxy Server for Google Play" switch enabled? I'm asking because it gets annoying when it stops when I'm emulating the purchase of packs in a game I play.

Information that may help you help me solve my issue!
L.P. Version- 8.3.1
Game- Jurassic World The Game
Device- Rooted Samsung Galaxy Tab4

Thanks for any help!

[FREE] Clamor : street poems

Hi guys,

I would like to introduce you to my first app which is very simple (maybe too basic but I'm still proud of it!).

Here is the principle : you can leave a little message which reflects your mood at your current geographical position. When people pass by, they will be able to read your message and like it.

Use it to become a street poet, place messages in remote places, organize treasure hunts and many other crazy things!

Have fun and send me your feedback!

https://play.google.com/store/apps/details?id=com.wonderful.clamor

I hate ZTE ZMAX pro z981!..

I got ripped off so bad on this one. This phone is always doing something to cause me to have to hard srest and create a new account. I talked with a dude at metro PC's and he said that they were getting a lot of returns on these phones . Something about the third party in the phone is what's causing all the problems. IDK?. I'm buying a new phone in a few days anyways and this one is taking a swim... Anyways, if any one else is having similar problems, drop a line please. Thanks everyone

Open Beta 19 & 11 for Oneplus 6 & 6T

OnePlus have just started the Open Beta 19 & 11 OTA roll out for the OnePlus 6 & 6T to test new features and fixes that may or may not, come to future firmware updates. You will only receive this test firmware OTA if you are already on their Open Beta releases.

6aWWyqbl.jpg


Camera version is still 3.0.37

Android Security patch is May 2019

This is the 11th Open Beta release for the 6T in 149 days = 1 update, on average, every 13.5 days.

(N.B. Open Beta is NOT available for the T-Mobile (USA) carrier minority variant)

Help Battery drainage and internet errors

Hello,
my phone is acting weird and I'd like some advice on it if possible:

- My battery drains super fast - it takes about 6-5 hours or less of normal usage to go from 100% to zero. It started about a week ago.

- Sometimes it just wont connect to the internet. Google starts up, it provides search results, but I cannot open any of the pages. Apps that require internet connection (a weather forecast, for example) wont connect either. When I restart my device, they seem to work again just fine. This problem also started about the same time as my battery issue.

Does anyone experience similar issues? What could be the problem?

S10 Plus Bluetooth Issue with PS4 Controller

I am facing Bluetooth issue when I connect my samsung galaxy s10 plus to PS4 controller via bluetooth.
connection method: I first press (PS button+share) and it is flashing, to make it visible for the mobile. Then I turn on bluetooth on my s10 plus to connect it. After that, it shows connected on the mobile and the light is on the PS4 controller being stable(white color). But its not working when I use the controller to move or press any button. Besides, when I want to disconnect the bluetooth from mobile, the light on the controller keeps working like it is still connected. And the bluetooth of the s10 plus gets stuck until I restart my phone. The PS4 controller light turns off as well.
solutions tried with no luck:
1- I went to setting>apps>show system app>bluetooth>storage>deleted cash and data>restarted phone

2- I did PS4 controller reset(the small hole in the back) but nothing happened as well

3- The only way now work is to connect the PS4 controller via cable.

appreciate if any one can help on this to solve this. Noting that this issue happens only between the mobile and the PS4 controller.
Thanks

ExpandableListAdapter | Remove Group and Add Child - both on button click

I'm building a small application using Firebase Real Time Database.

The app lists shifts per given date.

Each shift is displayed as a group item and every employee that is registered to this shift is displayed as a child in that group.

I used an ArrayList of ParentHeader class for the group-items and an ArrayList of Strings for the children-items (to list the employee's name) - This may change in the future for a more complex object.

This is my code:
Code:
public class DateActivity extends ExpandableListActivity {
   // date, isAdmin and name are passed to this activity using shared preferences
       private String date, name;
       private boolean isAdmin;
       // Adapter declaration
       private CustomExpandableListAdapter mAdapter;
       // ArrayList to store group items
       private ArrayList<ParentHeader> parents = new ArrayList<>();

       @Override
       protected void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.activity_date);
    // initialize date, isAdmin, name here

           // Fetch all shifts for selected date from Firebase
           Validator.fetchShiftsPerDayFromDB(date, new Callback()
           {
               @Override
               void shiftsCallback(ArrayList<Shift> shifts)
               {
                   super.shiftsCallback(shifts);
                   if (shifts == null)
                       return;

                   for(Shift shift : shifts){
                       parents.add(new ParentHeader(shift));
                   }

                   mAdapter = new CustomExpandableListAdapter();
                   setListAdapter(mAdapter);
               }
           });
}

   private class CustomExpandableListAdapter extends BaseExpandableListAdapter
   {
       private LayoutInflater inflater;

       public CustomExpandableListAdapter()
       {
           // Create Layout Inflator
           inflater = LayoutInflater.from(DateActivity.this);
       }

       @Override
       public int getGroupCount()
       {
           return parents.size();
       }

       @Override
       public int getChildrenCount(int groupPosition)
       {
           int size = 0;
           if(parents.get(groupPosition).getEmployeesList() != null)
               size = parents.get(groupPosition).getEmployeesList().size();
           return size;
       }

       @Override
       public Object getGroup(int groupPosition)
       {
           return parents.get(groupPosition);
       }

       @Override
       public Object getChild(int groupPosition, int childPosition)
       {
           return parents.get(groupPosition).getEmployeesList().get(childPosition);
       }

       @Override
       public long getGroupId(int groupPosition)
       {
           return groupPosition;
       }

       @Override
       public long getChildId(int groupPosition, int childPosition)
       {
           return childPosition;
       }

     @Override
       public boolean hasStableIds()
       {
           return true;
       }

       @Override
       public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parentView)
       {
               final ParentHeader parentHeader = parents.get(groupPosition);

               // Inflate group_row.xml file for group rows
               convertView = inflater.inflate(R.layout.group_row, parentView, false);
// Get group_row.xml file elements and set values here

           //Add User to selected shift
           convertView.findViewById(R.id.add).setOnClickListener(v -> {
               //TODO insert constraints
              Validator.addUserToShiftInDB(parentHeader.getShift().getKey(), date, name, new Callback() {
                  @Override
                  void onUserAssignedToShiftCallback() {
                      super.onUserAssignedToShiftCallback();
                       // TODO attach as child-item to chosen group-item
                  }
              });

           });

               convertView.findViewById(R.id.delete).setOnClickListener(v -> {
                   if(isAdmin){
                       //TODO open confirmation window
                       Validator.deleteShiftFromDateInDB(parentHeader.getShift().getKey(), date, new Callback() {
                           @Override
                           void onDeletedShiftCallback() {
                               super.onDeletedShiftCallback();
// shift gets deleted in Firebase but the expandable list does not refresh
                               parents.remove(groupPosition);
                               mAdapter.notifyDataSetChanged();
                           }
                       });

                   }
                   else{
                       Toast.makeText(getApplicationContext(),"Admin privileges required", Toast.LENGTH_SHORT).show();
                   }
               });
               return convertView;
       }

         @Override
       public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parentView)
       {
           final ParentHeader parentHeader = parents.get(groupPosition);
           final String childString = parentHeader.getEmployeesList().get(childPosition);

           // Inflate child_row.xml file for child rows
           convertView = inflater.inflate(R.layout.child_row, parentView, false);

           // Get child_row.xml file elements and set values here

           return convertView;
       }

       @Override
       public boolean isChildSelectable(int groupPosition, int childPosition)
       {
           return true;
       }

       @Override
       public boolean areAllItemsEnabled()
       {
           return true;
       }

       @Override
       public boolean isEmpty()
       {
           return ((parents == null) || parents.isEmpty());
       }

       @Override
       public void notifyDataSetChanged()
       {
           // Refresh List rows
           super.notifyDataSetChanged();
       }
   }
}

The ParentHeader class which stores data on each group-item.
Code:
public class ParentHeader {
   private Shift shift;
   private boolean isDeleteButtonClicked, isAddButtonClicked, isHeaderClicked;
   // Array to store child objects
   private ArrayList<String> employeesList = new ArrayList<>();

   public ParentHeader() { }

   public ParentHeader(Shift shift) {
       this.shift = shift;
   }

// Getters/Setters here
}

and finally the Shift class which stores data for every shift.
Code:
public class Shift {
   private String startTime, endTime, name, key;
   private Integer wage, numOfEmps, employees;


   public Shift(){}

   public Shift(String name, String startTime, String endTime, Integer wage, Integer numOfEmps, Integer employees) {
       this.startTime = startTime;
       this.endTime = endTime;
       this.name = name;
       this.wage = wage;
       this.numOfEmps = numOfEmps;
       this.employees = employees;
// key field is assigned a value when fetching each shift from firebase using .getKey() method

   }
//Getters/Setters here
}

First Problem

Removing a group item from an ExpandableListAdapter on button click on the parent-item.

As you can see above I'm calling parents.remove and then notifyDataSetChanged in my getGroupView method, but the list does not get refreshed.

It does however work if I reload the activity or by moving to another activity and then back to this one.

I wish for it to work dynamically.

Second Problem

Adding a child to a group on button click of the parent-item.

My database is structured as follows:
Code:
"20190528" : {
    "-LfvCgavw5bYUJzULE6E" : {
      "employees" : 0,
      "endTime" : "00:00",
      "name" : "test1",
      "numOfEmps" : 2,
      "startTime" : "00:00",
      "wage" : 2
    }
  }

When a new shift has been added to a date by the Admin.

Now I wish for every User to be able to assign themselves to one of the shifts and for their name to be displayed as a child-item for that group-item shift.

After they click their chosen group-item shift, their data should be stored in Firebase like so:
Code:
"20190528" : {
    "-LfvCgavw5bYUJzULE6E" : {
      "employees" : {
        "generatedKey1" : "John Smith",
        "generatedKey2" : "Jane Doe"
      },
      "endTime" : "00:00",
      "name" : "test1",
      "numOfEmps" : 2,
      "startTime" : "00:00",
      "wage" : 2
    }
  }

I wish for every name stored under employees to be displayed as a child-item under its corresponding group-item shift. Dynamically of course.

I'd appreciate help in solving these two problems. I'm new to Android developement and do not have much experience with it.

Thank you.

Filter

Back
Top Bottom