- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我是 Android 新手,我正在从事一个项目,该项目旨在收集手机观察到的所有细胞信息。我使用了 TelephonyManager.getAllCellInfo()
方法,但它总是返回 null
。
我的代码::
public class NetworkCoverageActivity extends AppCompatActivity {
private String str;
private TextView TV;
private Button getCellsInfoBtn;
private TelephonyManager TM;
private List<CellInfo> cellInfoList;
private PhoneStateListener PSL;
private int event;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_network_coverage);
TV = (TextView)findViewById(R.id.iv);
getCellsInfoBtn = (Button)findViewById(R.id.getCellsInfoBtn);
TM = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
PSL = new PhoneStateListener();
event = PSL.LISTEN_CELL_INFO | PSL.LISTEN_CELL_LOCATION;
getCellsInfoBtn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
TM.listen(PSL, event);
cellInfoList = TM.getAllCellInfo();
if(cellInfoList != null)
TV.append("cellInfoList = null");
else{
...
}
}
});
}
我正在使用 android 4.4.2 level 17 并将最低 API 级别设置为 17。并且我尝试从 GSM 网络收集信息。
此外,我还在 AndroidManifest.xml
中添加了以下权限:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
最佳答案
我的问题已经得到解答了。已替换 getAllCellInfo()
功能由 getNeighboringCellInfo()
功能,虽然我运行的 android level 17 应该支持 getAllCellInfo()
功能和getNeighboringCellInfo()
应该不再支持该功能。无论如何,以下是解决方案。
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");
}
});
}
}
关于java - Android getAllCellInfo() 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39436761/
我正在使用 getAllCellInfo 从我的手机(unrooted LG G5 - 它的值(value))获取服务和相邻小区信息,但该函数返回所有相邻测量塔的重复数据。在我所在的地区,我的测试数据
有谁知道从 TelephonyManager.getAllCellInfo() 返回的列表中的单元格索引是否与 SIM 插槽编号相关? 我正在使用 Android API 24... 经过一些实验,似
我是 Android 新手,我正在从事一个项目,该项目旨在收集手机观察到的所有细胞信息。我使用了 TelephonyManager.getAllCellInfo() 方法,但它总是返回 null。 我
我有一个 Android 应用程序可以获取手机信号塔的信息。我使用此 getAllCellInfo() 来获取主单元格和相邻单元格的信息。我将 ACCESS_COARSE_LOCATION 权限包含在
我目前正在为我的大学研究项目开发 Android 应用程序。此应用程序应该能够读取附近 GSM 基站的 RSSI 级别。我编写了以下函数,它成功读取了附近小区的 RSSI 电平。我每 200 毫秒调用
我阅读了所有关于 getAllCellInfo() 的帖子并且遇到了类似 this 的情况.下面发布的代码在 Android 6 (OnePlus One) 上运行良好,但在 Google Nexus
最近我在尝试使用 Android 设备获取相邻小区的信息。而且我试过很多品牌的安卓手机,比如三星,htc。结果只是Htc可以得到邻区信息。我使用的函数是 TelephonyMananger.getNe
Android 有一个 API 方法:getAllCellInfo() “从设备上的所有 radio 返回所有观察到的小区信息,包括主小区和相邻小区”。在 iOS 上,我找到了 CTCarrier类以
我的 Android 版本是 4.2.1,我正在尝试使用 TelephonyManager.getAllCellInfo() 方法。在我的 list 文件中,我拥有 ACCESS_COARSE_UPD
我是一名优秀的程序员,十分优秀!