Android getAllCellInfo() returns null
I have got the solution of my question. that's replaced getAllCellInfo()
function by getNeighboringCellInfo()
function, although I am running with android level 17 that should be support getAllCellInfo()
function and getNeighboringCellInfo()
function should be no longer supported.
Anyway, the following is the solution.
package ayad.bslm.com.networkcoverage;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.NeighboringCellInfo;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.List;
public class NetworkCoverageActivity extends AppCompatActivity {
private TextView TV;
private TelephonyManager TM;
private List<NeighboringCellInfo> neighboringCellInfoList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_network_coverage);
TV = (TextView)findViewById(R.id.iv);
Button getCellsInfoBtn = (Button)findViewById(R.id.getCellsInfoBtn);
TM = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
getCellsInfoBtn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
neighboringCellInfoList = TM.getNeighboringCellInfo();
if(neighboringCellInfoList == null)
TV.setText("neighboringCellInfoList == null\n");
else
TV.setText("There are " + neighboringCellInfoList.size() + " Cells\n");
}
});
}
}
getAllCellInfo() returns empty list in honor 9n
If the user has disabled device location on a device running Android 9, the following methods don't provide results:
getAllCellInfo()
listen()
getCellLocation()
getNeighboringCellInfo()
Related Topics
Delete File from Internal Storage
Gcm Push Notification with ASP.NET
Moving an Image Using Accelerometer of Android
How to Send Location of the Device on Server When Needed
Inflate Layout Programmatically Within Another Layout
Could Not Find Com.Android.Tools.Lint:Lint-Gradle Android Studio 3
How to Create an Android Service That Listens for Hardware Key Presses
How to Close the Status Bar/Notification Panel After Notification Button Click
Why Is Calling Process.Killprocess(Process.Mypid()) a Bad Idea
Android Audiotrack Playing .Wav File, Getting Only White Noise
Android Studio- Program Type Already Present: Com.Google.Android.Gms.Internal.Measurement.Zzwp
Retrofit2: Modifying Request Body in Okhttp Interceptor
Saving Arraylists in SQLite Databases
Android Custom Layout - Ondraw() Never Gets Called
Install App via Usb: the Device Is Temporarily Restricted