Answer the question
In order to leave comments, you need to log in
How to fix error while running android app?
My application was tested on several virtual and on several real devices. The problem is, on most phones everything works fine, but now on two devices there are changes in the application that I don’t understand. Firstly, the strangest thing is that the application does not load resources, none at all, pictures (I inserted my icon), it does not see string resources either, maybe something else does not load, I don’t know. But the most annoying thing is that the program does not fulfill its main task. I have been tinkering with the possible cause of this error for a long time, to be honest, I almost didn’t think of anything)) At the moment, I realized that when I click on the application login button when logging in, according to the application logic, I should go to the second screen, SecondScreen. But when I try to switch, the application crashes. Here is my error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.developer_4.test_login/com.example.developer_4.test_login.SecondScreen}: android.content.res.Resources$NotFoundException: String resource ID #0x7f0f0040
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2792)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2870)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1601)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:172)
at android.app.ActivityThread.main(ActivityThread.java:6590)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f0f0040
at android.content.res.Resources.getText(Resources.java:339)
at android.content.Context.getText(Context.java:543)
at android.support.v7.widget.Toolbar.setNavigationContentDescription(Toolbar.java:903)
at android.support.v7.app.ActionBarDrawerToggle$ToolbarCompatDelegate.setActionBarDescription(ActionBarDrawerToggle.java:608)
at android.support.v7.app.ActionBarDrawerToggle$ToolbarCompatDelegate.setActionBarUpIndicator(ActionBarDrawerToggle.java:600)
at android.support.v7.app.ActionBarDrawerToggle.setActionBarUpIndicator(ActionBarDrawerToggle.java:495)
at android.support.v7.app.ActionBarDrawerToggle.syncState(ActionBarDrawerToggle.java:242)
at com.example.developer_4.test_login.SecondScreen.onCreate(SecondScreen.java:75)
at android.app.Activity.performCreate(Activity.java:7023)
at android.app.Activity.performCreate(Activity.java:7014)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
... 9 more
public class SecondScreen extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, Received.OnFragmentInteractionListener, Sent.OnFragmentInteractionListener {
SharedPreferences tok_pref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second_screen);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
TabLayout tabLayout = findViewById(R.id.tabLayout);
tabLayout.addTab(tabLayout.newTab().setText(R.string.received));
tabLayout.addTab(tabLayout.newTab().setText(R.string.sent));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = findViewById(R.id.pager);
final PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.setOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
/* FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});*/
DrawerLayout drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.second_screen, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
if (id == R.id.logout) {
tok_pref = getSharedPreferences("access_token", 0);
tok_pref.edit().remove("access_token").apply();
Intent intent = new Intent(SecondScreen.this,LoginActivity.class);
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera) {
Intent intent = new Intent(this, SecondScreen.class);
startActivity(intent);
} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
@Override
public void onFragmentInteraction(Uri uri) {
}
}
Answer the question
In order to leave comments, you need to log in
at com.example.developer_4.test_login.SecondScreen.onCreate(SecondScreen.java:75)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question