在我的片段中,当我尝试启动共享意图时,它会关闭我的应用程序。我希望该意图出现在我的应用程序顶部,并且当用户完成共享并按下返回按钮时,我的应用程序会出现。这是我的清单文件。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.joyfm.activity"
android:versionCode="5"
android:versionName="1.4" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:theme="@style/Theme.Sherlock"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/logo_launcher">
<activity
android:theme="@style/Theme.Sherlock"
android:name="com.joyfm.activity.MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.joyfm.activity.SplashActivity"
android:theme="@style/Theme.Sherlock"
android:launchMode="singleTask"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这是我编辑后的片段中的代码:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
String authorInformation = "<i><BR>" + news.getAuthorInfo() + "<BR>\u00A9 www.myjoyonline.com</i>";
ScrollView layout = (ScrollView) inflater.inflate(R.layout.news_viewer, container, false);
TextView title = (TextView) layout.findViewById(R.id.txtTitle);
TextView summaryDetails = (TextView) layout.findViewById(R.id.summaryDetails);
TextView date = (TextView) layout.findViewById(R.id.txtNewsDate);
TextView copyRight = (TextView) layout.findViewById(R.id.txtCopyRight);
TextView newsDetails = (TextView) layout.findViewById(R.id.txtNewsDetails);
ImageViewSpinner image = (ImageViewSpinner) layout.findViewById(R.id.thumbNail);
title.setText(Html.fromHtml(news.getTitle()));
summaryDetails.setText(Html.fromHtml(ITALIC_START + news.getDescription() + ITALICS_END));
date.setText(Html.fromHtml(ITALIC_START + news.getDate() + ITALICS_END));
newsDetails.setText(Html.fromHtml(news.getNewsItem()));
copyRight.setText(Html.fromHtml(authorInformation));
if(news.getThumbnailUrl().trim().length() > 0)
{
imageDownloader.download(image, news.getThumbnailUrl(), null);
}else
{
image.setVisibility(View.GONE);
}
shareContentSubject = title.getText();
shareContentDetails = newsDetails.getText();
image.setClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
try
{
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, SHARED_SUBJECT + shareContentSubject);
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareContentDetails);
startActivity(Intent.createChooser(sharingIntent, "Share with"));
}catch(Exception ex)
{
ex.printStackTrace();
}
}
});
return layout;
}
请帮忙,我一直在苦苦挣扎并尝试了所有方法。
@Override protected void onUserLeaveHint() { super.onUserLeaveHint(); finish(); }
- Lawrence O