I'm trying to send content through Intent (I think this is the reason of my error) and I constantly get ActivityNotFoundException
.
Here's the class which is sending data to Tab1.class
(String called temperature)
I found similar question on stack where someone wrote that problem is caused by instantiating the intent before the activity has gone through its life cycle methods but I'm not sure if it is a problem and what should I do to fix it
public class ChooseLayout extends AppCompatActivity implements View.OnClickListener {
EditText editText;
Button button;
Weather weather;
Parser parser = new Parser();
SharedPreferences sharedPreferences;
String temperature, preassure,WindSpeed,WindDirection,Humidity,ViewDescription;
boolean isChecked = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.choose_layout);
editText = (EditText) findViewById(R.id.editText);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!isOnline()) {
Toast.makeText(getApplicationContext(), "Cannot connect to network, data will be restore from file with last downloaded data...", Toast.LENGTH_LONG).show();
} else {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
weather = parser.getWeatherForLocation(editText.getText() + "");
runOnUiThread(new Runnable() {
@Override
public void run() {
editText.setText(weather.getCity() + ", " + weather.getCountry());
temperature = weather.getTemperature();
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
});
t.start();
}
Intent intent = new Intent(getApplicationContext(),Tab1.class);
intent.putExtra("temperature", temperature);
startActivity(intent);
}
});
sharedPreferences = getSharedPreferences("file_name", MODE_PRIVATE);
}
I have declared this activity in AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.chirag.slidingtabsusingviewpager">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ChooseLayout"></activity>
</application>
</manifest>