在我的片段中,當我嘗試共享意圖時,午餐會關閉我的應用程序。我希望意圖出現在我的應用程序之上,當用戶完成共享並按下後退按鈕時,我希望我的應用程序出現。這裏是我的清單文件Android:開始共享意圖關閉我的活動
<?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>
這是我在我的EDITED片段代碼:
@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;
}
請幫幫忙,我一直在努力與這個用盡一切方法。
爲什麼你需要內部啓動活動:??getActivity()runOnUiThread(新的Runnable() – Gyonder 2013-03-02 09:19:48
其實,真正爲什麼打開主UI線程的意圖這是一個錯誤,請出示錯誤logcat顯示的你 – IamStalker 2013-03-02 09:34:02
我已經改變了它,你可以看到上面,但同樣的問題,意圖關閉活動,也沒有錯誤messages.Any想法? – 2013-03-02 09:44:52