我找到了很多代码来获取cell-id和位置区域代码,我使用下面的代码来获取cell-id和位置区域代码.
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager.getCellLocation();
int cid = cellLocation.getCid();
int lac = cellLocation.getLac();
Run Code Online (Sandbox Code Playgroud)
问题是,当我使用airtel-sim卡时,它工作正常并给出cell-id = 4331和loc = 610.但是当我使用relience-sim卡时,它会给出错误的结果cell-id = 11541和loc = 18823.我怎么解决这个问题?
我有一个 Activity,并为其创建了一个视图模型。我创建了不同的类,如 UiUtil(显示、隐藏视图、隐藏键盘)、网络层、数据库层、AppUtil(用于常见功能,如集合检查、字符串验证、日期转换等)
我的问题是,在MVVM设计模式中,Activity可以直接使用这些实用程序类,或者它需要通过视图模型使用这些类,如果它通过视图模型,那么在视图模型中我必须编写一个只调用实用程序类的方法方法 。像下面的 TimeDateManager 是视图模型中使用的实用程序类
class HomeViewModel: BaseViewModel()
{
fun prepareTimeAmPmToDisplay(context: Context, alarm: Alarm): String
{
return TimeDateManager.prepareTimeAmPmToDisplay(context, alarm)
}
}
在下面的xml代码中,我显示CheckBox它看起来比正常大小更大.但是在其他xml代码上它看起来很好.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="20dip"
android:background="@android:color/transparent"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_bg_provide_shadow"
android:padding="@dimen/padding_small" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/dialog_back_gradient"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1_hiddenactivity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="10dip"
android:text="You have disabled Mobile Data in the settings.An app is trying to use it.Do you want to allow?"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#40342c" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:orientation="vertical"
android:padding="10dip" >
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:clickable="false"
android:text="Ashis Sharma " />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip" > …Run Code Online (Sandbox Code Playgroud) 我Activity从ActivityA 开始B startActivityForResult(),ActivityB是半透明的,然后是Activity的A方法
protected void onActivityResult(int requestCode, int resultCode, Intent data) {}
Run Code Online (Sandbox Code Playgroud)
ActivityB 立即开始工作.
请建议.
在双卡手机中,数据漫游选项通常位于“设置”>“数据使用”和双卡设置页面中。是否可以以编程方式打开它?