我从gmail下载了一个文件。下载完成后,我需要能够点击通知,在我的应用程序中打开下载的文件。 我的文件类型是csv。
点击上面通过我的app.how打开的下载文件打开?
<activity
android:label="@string/app_name"
android:name=".Fakeactivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:host="*" />
<data android:mimeType="text/comma-separated-values" />
<data android:pathPattern=".*\\.csv" />
</intent-filter>
</activity>
使用上面的代码通过我的app.in FakeActivty打开csv文件我已经编写了读取csv文件的代码。
答案 0 :(得分:0)
have you implement function of click on notification and your program can handle open csv files here is a code for read csv file here is the code of opening activity which will response for show the csv file
final Intent intent = new Intent(this, CSVClass.class);
\\ data you want to send to CSV
intent.putExtra("key", "value");
final PendingIntent contentIntent =
PendingIntent.getActivity(this,
0, intent), 0);
public class CSVFile {
InputStream inputStream;
public CSVFile(InputStream inputStream){
this.inputStream = inputStream;
}
public List read(){
List resultList = new ArrayList();
BufferedReader reader = new BufferedReader(new
InputStreamReader(inputStream));
try {
String csvLine;
while ((csvLine = reader.readLine()) != null) {
String[] row = csvLine.split(",");
resultList.add(row);
}
}
catch (IOException ex) {
throw new RuntimeException("Error in reading CSV file: "+ex);
}
finally {
try {
inputStream.close();
}
catch (IOException e) {
throw new RuntimeException("Error while closing input
stream: "+e);
}
}
return resultList;
}
}