错误:
android.security.KeyChainException: java.lang.IllegalStateException: uid 10111 doesn't have permission to access the requested alias
Run Code Online (Sandbox Code Playgroud)
码:
new Thread(new Runnable() {
public void run() {
try {
X509Certificate[] myCertificates=KeyChain.getCertificateChain(MainActivity.this, "ServerCertificate");
if(myCertificates!=null)
{
System.out.println("myCertificates size "+myCertificates.length);
for(int i=0;i<myCertificates.length;i++)
{
System.out.println("myCertificates i= "+i+" "+myCertificates[i]);
}
}
} catch (KeyChainException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
Run Code Online (Sandbox Code Playgroud) 我创建了一个简单的ListView包含checkedTextView.
我想在用户点击listView行时添加一个监听器,
1 - 将检查textView.
2 - 如果列表中有另一个文本视图已选中,则取消选中.
这是我写的代码到现在为止:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ArrayList<String> mStrings = new ArrayList<String>();
for(int i=0; i<30; i++) {
mStrings.add("Item " + i);
}
setListAdapter( new MultiAdapter(this, mStrings));
/* Configure ListView */
ListView lv = getListView();
lv.setOnItemClickListener(new ItemClick());
}
class ItemClick implements OnItemClickListener {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
}
private class MultiAdapter extends ArrayAdapter<String> {
private ArrayList<String> mItems;
public MultiAdapter(Context context, ArrayList<String> mStrings) {
super(context, …Run Code Online (Sandbox Code Playgroud) 我想转换一个串号开头00,以+如0046760963101来+46760963101.有没有解决办法通过正则表达式来处理它?
如果不是你推荐什么解决方案?
附录:
如果它以000或更多开头,我不想用+号替换.
所以我想测试2 1NSString,看看它们在我输入时是否相同:
NSString *theOriginalString = [NSString stringWithFormat:@"Superman"];
NSString *theTypedString = [textView string];
Run Code Online (Sandbox Code Playgroud)
我想在输入时查看是否TypedString有错,如果有人输入了错误的答案,则会弹出警告.
先感谢您.
我有以下ViewModel类:
class PersonViewModel(
context: Application,
private val dataSource: MoviesRemoteDataSource)
: AndroidViewModel(context) {
internal val compositeDisposable = CompositeDisposable()
val person: ObservableField<Person>()
private val isVisible = ObservableBoolean(false)
fun showPerson(personId: String) {
val personSubscription = dataSource.getPerson(personId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ person ->
isVisible.set(true)
this.person.set(person)
}
) { throwable -> Timber.e(throwable) }
compositeDisposable.add(personSubscription)
}
}
Run Code Online (Sandbox Code Playgroud)
这是Person类:
class Person(
@SerializedName("birthday")
var birthDay: String?,
@SerializedName("deathday")
var deathDay: String?,
var id: Int,
@SerializedName("also_known_as")
var alsoKnowAs: List<String>,
var biography: String,
@SerializedName("place_of_birth")
var placeOfBirth: String?)
Run Code Online (Sandbox Code Playgroud)
它在ViewModel的这一行显示错误:
val person: ObservableField<Person>()
Run Code Online (Sandbox Code Playgroud)
它说 …
我已经开始学习Jetpack compose。我正在从 Google 检查此示例:https://github.com/android/compose-samples/blob/main/Crane/app/src/main/java/androidx/compose/samples/crane/home/MainActivity.kt
如您所见,MainScreen 可组合函数是文件中的方法,而不是 MainActivity 类中的内部函数。MainScreen 尚未在其他任何地方使用过。那么为什么不在Activity中将其定义为私有内部函数呢?
您能向我描述一下原因吗?