http://www.vogella.com에 대한 링크 및 추가 검색으로 내 문제를 해결했습니다. 안드로이드 매니페스트 • Android - 사용자가 앱으로 텍스트 파일을 열 수 있습니다.
: 자바 활동 •<uses-sdk android:minSdkVersion="8" />
<supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:process="IPP.EZPadd">
<activity
android:label="@string/app_name"
android:name=".EZPaddActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
</application>
:
public void open_on_start()
{
Intent i = getIntent();
Uri data = i.getData();
if (data == null)
{
return;
}
URL url;
String startFile = "";
try
{
url = new URL(data.getScheme(), data.getHost(), data.getPath());
startFile = url.toString().replace("file:", "");
}
catch (Exception ex)
{
Toast.makeText(this, "Error:\n" + ex.getMessage().toString(), Toast.LENGTH_LONG).show();
return;
}
if (startFile == null)
{
return;
}
StringBuilder text = new StringBuilder();
can = false;
sel = false;
try
{
file = new File(CurDir, startFile);
reader = new BufferedReader(new FileReader(file));
String line;
while ((line = reader.readLine()) != null)
{
text.append(line);
text.append('\n');
}
}
catch (Exception e)
{
Toast.makeText(this, "Error:\n" + e.getMessage().toString(), Toast.LENGTH_LONG).show();
}
TextEditor.setText(text);
FileName.setText(startFile);
}
링크 당신에게 사이먼 감사합니다, 그것은 매우 도움이되었다. 나는 처음에는 그것을 건너 뛰었 기 때문에 파일을로드하지 않고 그 문제에 부딪혔다.
그게 무슨 뜻인지 모르겠다. 기본적으로 열 옵션을 추가하려고했다. – Timberwolf
"사용자가 텍스트 파일을 열 때 특정 의도를 처리하도록 앱 목록에 내 앱을 표시하려면 어떻게해야합니까?" 미안, 나는 당신이 주제에 관해서 당신의 질문만큼 혼란 스럽다고 생각한다;) – Simon
그리고 나의 활동을 통해 전달 된 데이터를 다루는 방법. – Timberwolf