Skip to content
Snippets Groups Projects
Commit 8f645b29 authored by venkat's avatar venkat
Browse files

link for sharing

parent 5fb70fec
No related branches found
No related tags found
No related merge requests found
package com.example.venkat.and;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.speech.RecognizerIntent;
import android.support.v7.app.AppCompatActivity;
......@@ -10,6 +11,7 @@ import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
......@@ -99,19 +101,40 @@ public class Generate extends AppCompatActivity {
sb.append(s);
String fl="history.txt";
textView.setText("Waiting for the question");
String FILE_NAME = "history.txt";
try {
OutputStreamWriter out = new OutputStreamWriter(openFileOutput(fl,0));
out.write(s);
out.close();
} catch (FileNotFoundException e) {
FileOutputStream fos = openFileOutput(FILE_NAME, Context.MODE_PRIVATE);
fos.write(s.toString().getBytes());
fos.close();
Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}
BufferedReader bufferedReader ;
String content = "hello world";
File file1;
FileOutputStream outputStream;
try {
// file = File.createTempFile("MyCache", null, getCacheDir());
file1 = new File(getCacheDir(), "MyCache");
outputStream = new FileOutputStream(file1);
outputStream.write(content.getBytes());
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
BufferedReader bufferedReader ;
String file=null;
s=s.toLowerCase();
Toast.makeText(this, "in this fn", Toast.LENGTH_SHORT).show();
//Toast.makeText(this, "in this fn", Toast.LENGTH_SHORT).show();
try {
bufferedReader =new BufferedReader(new InputStreamReader(getAssets().open("INDEX.txt")));
String st;
......@@ -121,7 +144,7 @@ public class Generate extends AppCompatActivity {
if(s.equals(st)==true)
{
file=bufferedReader.readLine();
Toast.makeText(this, file, Toast.LENGTH_SHORT).show();
// Toast.makeText(this, file, Toast.LENGTH_SHORT).show();
bufferedReader.close();
break;
}
......
......@@ -104,6 +104,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
int t=10;
Toast.makeText(MainActivity.this, ""+star, Toast.LENGTH_SHORT).show();
dialog.cancel();
Toast.makeText(MainActivity.this, "Thank you", Toast.LENGTH_SHORT).show();
}
});
......@@ -116,7 +119,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "The link is still under work";
String shareBody = "https://drive.google.com/open?id=0B9gW072mnYQzbk9nWVNXZnhqaFU";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
......
......@@ -3,6 +3,7 @@ package com.example.venkat.and;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
......@@ -14,6 +15,7 @@ import android.widget.Toast;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
......@@ -28,7 +30,7 @@ public class history extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
Toast.makeText(this, "open", Toast.LENGTH_SHORT).show();
BufferedReader reader = null;
ArrayList<String> s =new ArrayList<String>();
// String s[]={};
......@@ -36,42 +38,76 @@ public class history extends AppCompatActivity {
final ListView listView=(ListView)findViewById(R.id.lst);
int t=0;
BufferedReader input = null;
File file = null;
try {
reader = new BufferedReader(
new InputStreamReader(getAssets().open("history.txt")));
file = new File(getCacheDir(), "MyCache"); // Pass getFilesDir() and "MyFile" to read file
input = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
String line;
StringBuffer buffer = new StringBuffer();
while ((line = input.readLine()) != null) {
text.append(line);
text.append('\n'); }
// do reading, usually loop until end of file reading
String mLine;
while ((mLine = reader.readLine()) != null) {
t=1;
// s[i]=mLine;
s.add(mLine);
text.append(mLine);
text.append('\n');
}
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "Error reading file!", Toast.LENGTH_LONG).show();
e.printStackTrace();
}finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
}
listView.setAdapter(listAdapter);
}
// TextView output = (TextView) findViewById(R.id.tu1);
// output.setText((CharSequence) text);
if(t!=0)
{
listView.setAdapter(listAdapter);
}
}
//
// try {
// reader = new BufferedReader(
// new InputStreamReader(getAssets().open("history.txt")));
//
//
// String mLine;
// while ((mLine = reader.readLine()) != null) {
// t=1;
// s.add(mLine);
//
// text.append(mLine);
// text.append('\n');
// }
// } catch (IOException e) {
// Toast.makeText(getApplicationContext(), "Error reading file!", Toast.LENGTH_LONG).show();
// e.printStackTrace();
// } finally {
// if (reader != null) {
// try {
// reader.close();
// } catch (IOException e) {
//
// }
// }
// if(t!=0)
// {
//
// listView.setAdapter(listAdapter);
// }
//
// }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment