Hello all I have implemented a back button in the action bar in my app but I dont know how to return from an activity to a fragment or a fragment to fragment. so if someone could show me how to return from an activity to a fragment or even a fragment to another fragment that would be amazing. Here is the code i have right now
public class Article extends Activity{
private WebView webview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.articleview);
// etc...
getActionBar().setDisplayHomeAsUpEnabled(true);
Bundle b = getIntent().getExtras();
String KEY_LINK = b.getString("b");
String url = getIntent().getStringExtra("key");
WebView myWebView = (WebView) findViewById(R.id.webView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl(url);
myWebView.loadUrl(KEY_LINK);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
and in my manifest I have
<activity
android:name=".Article"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="com.NTCI.graffiti.Article" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.NTCI.graffiti.MainActivity" />
</activity>
but i want it to return to its host fragment not the main activity I have it set to. Any thoughts?