Android cannot start Activity - java.lang.RuntimeException: Unable to start activity ComponentInfo
Tag : java , By : Willem van Schevikho
Date : March 29 2020, 07:55 AM
I wish this help you If anyone stumbles on this in the future I want to make sure that you can get an answer... The problem was that certain tags that are available only to Material and Android 5.0+ were being used in my styles. So I instead made a res/values-v21/styles.xml folder and put my appropriate settings in there. That fixed the issue.
|
Choose the language of the android application on start of activity
Date : March 29 2020, 07:55 AM
like below fixes the issue I want to set the language of my application choosed at start of activity, the value of this language is defined in SharedPreferences , ok try to change your code like that : Resources res = getResources();
// Change locale settings in the app.
DisplayMetrics dm = res.getDisplayMetrics();
android.content.res.Configuration conf = res.getConfiguration();
conf.locale = new Locale("put the value that u get from SharedPreferences);
res.updateConfiguration(conf, dm);
|
change application language in start activity using SharedPreferences?
Date : March 29 2020, 07:55 AM
will help you i used below code to change language: , i found the answer: protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//some code here
if (last_local.equals("fa") && current_local.equals("en"))
setLocale("fa");
//some code here
}
public void setLocale(String languageToLoad){
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
SharedPreferences Settings=getSharedPreferences("Last Setting",1);
Settings.edit().putString("Locale Status", languageToLoad).commit();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
|
How to start Language and Input Intent through XML?
Date : March 29 2020, 07:55 AM
hope this fix your issue Nevermind I found an answer here. Since android:targetClass
android:targetPackage
ComponentName(String package, String class)
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.LanguageSettings" />
|
Start Activity and Pass Input through DialogFragment
Date : March 29 2020, 07:55 AM
Does that help I'm assuming that the filename EditText is in your inflated layout. You have to reference it via that inflated layout. View view = inflater.inflate(R.layout.activity_initialize_test, null);
final EditText editText = (EditText) view.findViewById(R.id.filename);
builder.setPositiveButton(R.string.start_test, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
String filename = editText.getText().toString();
Context context = getContext();
Intent intent = new Intent(context, InitializeTest.class);
intent.putExtra(FILENAME, filename);
context.startActivity(intent);
}
});
|