I have a few questions about the error code which you can see below:
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 But let's start first, this application was tested on several virtual and several real devices. The problem is, on most phones everything is working fine, but already on two devices there are incomprehensible changes in the application operation. First of all, the strangest thing is that the application does not load resources, no pictures at all (I inserted my icon), I don’t see string resources either, maybe I don’t know something else. But the most offensive is that the program does not perform its main task. Here is the code:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(activity_login); submitBtn = findViewById(R.id.btn_submit); submitBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { sendPost(); } }); Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable ex) { handleUncaughtException(thread, ex); } }); } public void handleUncaughtException(Thread thread, Throwable e) { String stackTrace = Log.getStackTraceString(e); String message = e.getMessage(); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"angoran16@gmail.com"}); intent.putExtra(Intent.EXTRA_SUBJECT, "MyApp Crash log file"); intent.putExtra(Intent.EXTRA_TEXT, stackTrace); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // required when starting from Application startActivity(intent); } public void sendPost() { final EditText titleEt = findViewById(R.id.login); final EditText bodyEt = findViewById(R.id.password); final String a = titleEt.getText().toString().trim(); final String b = bodyEt.getText().toString().trim(); final Button btn = findViewById(R.id.btn_submit); HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://сервер/") .client(client) .addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(ScalarsConverterFactory.create()) .build(); APIService mAPIService = retrofit.create(APIService.class); //retrofit.create(APIService.class); mAPIService.auth(new Post(a, b)).enqueue(new Callback<GetToken>() { @Override public void onResponse(@NonNull Call<GetToken> call, @NonNull Response<GetToken> response) { if (response.isSuccessful()) { Toast.makeText(LoginActivity.this, "Post submitted to API.", Toast.LENGTH_LONG).show(); Intent intent = new Intent(LoginActivity.this, SecondScreen.class); btn.getBackground().setColorFilter(Color.parseColor("#1cd000"), PorterDuff.Mode.MULTIPLY); //TextView txt = findViewById(R.id.access_token); String token = Objects.requireNonNull(response.body()).getAccess_token(); //txt.setText(token); startActivity(intent); tok_pref = getSharedPreferences("access_token", MODE_PRIVATE); SharedPreferences.Editor editor = tok_pref.edit(); editor.putString(ACCESS_TOKEN, token); editor.commit(); saveData(); titleEt.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.toString().trim().length() == 0) { btn.setEnabled(false); findViewById(R.id.btn_submit).getBackground().setColorFilter(Color.parseColor("#FF0000"), PorterDuff.Mode.MULTIPLY); } else { btn.setEnabled(true); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); } else { Toast.makeText(LoginActivity.this, "Unable to submit post to API.Error!!!", Toast.LENGTH_LONG).show(); findViewById(R.id.btn_submit).getBackground().setColorFilter(Color.parseColor("#FF0000"), PorterDuff.Mode.MULTIPLY); } } that is, as can be seen from the code, when I click on a button, I get a request to the server. In problem phones, when you press a button, it seems that the request is sent but then the application drops.
UPDATE
Here is the file of my SecondScreen:
package com.example.developer_4.test_login; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.NavigationView; import android.support.design.widget.Snackbar; import android.support.design.widget.TabLayout; import android.support.v4.view.GravityCompat; import android.support.v4.view.ViewPager; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import com.example.developer_4.test_login.Tabs.PagerAdapter; import com.example.developer_4.test_login.Tabs.Received; import com.example.developer_4.test_login.Tabs.Sent; public class SecondScreen extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, Received.OnFragmentInteractionListener, Sent.OnFragmentInteractionListener { @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("Received")); tabLayout.addTab(tabLayout.newTab().setText("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; } 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) { } } if the problem is in the layout file, then I have several of them, since I added nawdrawer activations.
Thank you all for the valuable advice, answers and criticism)). Thanks in advance for your help.
//txt.setText(token);Did you close before or after? - McDaggenactivity_loginfile uses a link to a string resource specific to the library support version ... Show your layout - Barmaley