• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps barcode and qr code programming

Code:
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;



public class MainActivity extends Activity {


static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";


@override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

}

public void scanBar(View v){

try{
Intent intent = new Intent(ACTION_SCAN);
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);
}catch (ActivityNotFoundException e){
showDialog(MainActivity.this, "No Scanner Found",
"Download a scanner code activity?", "Yes", "No").show();


}



}


public void scanQR(View v){

try{

Intent intent = new Intent(ACTION_SCAN);

intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

startActivityForResult(intent, 0);

}catch (ActivityNotFoundException e){

showDialog(MainActivity.this, "No Scanner Found",

"Download a scanner code activity?", "Yes", "No").show();

}

}



private static AlertDialog showDialog(final Activity act,

CharSequence title, CharSequence message,

CharSequence buttonYes,

CharSequence buttonNo) {


AlertDialog.Builder dowloadDialog = new AlertDialog.Builder(act);

dowloadDialog.setTitle(title).setMessage(message).setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {


@override

public void onClick(DialogInterface dialog, int which) {

Uri uri = Uri.parse("market://search?q=pname:" +

"com.google.zxing.client.android");


Intent intent = new Intent(Intent.ACTION_VIEW, uri);

try{

act.startActivity(intent);

} catch(ActivityNotFoundException e){


}


}

}).setNegativeButton(buttonNo, new DialogInterface.OnClickListener() {


@override

public void onClick(DialogInterface dialog, int which) {




}

});


return dowloadDialog.show();


}

@override

protected void onActivityResult(int requestCode, int resultCode, Intent intent){

if(requestCode == 0){

if(resultCode == RESULT_OK){

String contents = intent.getStringExtra("SCAN_RESULT");

String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

Toast.makeText(this, "Content:" + contents + "Format:" + format,

Toast.LENGTH_LONG).show();

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.product-open-data.com/search/"));

startActivity(browserIntent);




} else if (resultCode == RESULT_CANCELED) {

// Handle cancel

Toast toast = Toast.makeText(this, "Scan was Cancelled!", Toast.LENGTH_LONG);

toast.setGravity(Gravity.TOP, 25, 400);

toast.show();





}

}

}

}
 
Upvote 0
Hi Sanjit,

There are different barcode types for different industries and applications: UPC, EAN, Code-39 and Code-128. Codabar and GS1 Databar are typically used in healthcare. There is a standard for barcode format in use in healthcare industry. To get your app to work, you will need to determine the barcode type that will be imprinted for your product, then isolate medical products by checking for proper format before displaying the result.
 
Last edited:
  • Like
Reactions: HeavensSentSword
Upvote 0
Hi Sanjit,

There are different barcode types for different industries and applications: UPC, EAN, Code-39 and Code-128. Codabar and GS1 Databar are typically used in healthcare. There is a standard for barcode format in use in healthcare industry. To get your app to work, you will need to determine the barcode type that will be imprinted for your product, then isolate medical products by checking for proper format before displaying the result.
can you give the website for healthcare databases and help me with print statement lets say if my app scans a product that is not a medication product how to make it say invalid scan.
 
Upvote 0
Wait wait wait. Lets not get the FDA involved in this. They take thing a step to far. They are like the CIA but with no boundaries, no real authority, and a lot smaller budget.
please tell me the solution. programmed the app. I a m using the outpan database. all i need help with is when i scan the medicine product it prints the barcode or qr code scan to the outpan database search engine on its own. it scan takes me to the database and writes the search on its own. Then as i have been saying lets say i barcode or qr code scan a non medicine product it should print out invalid scan. that si all what i really need help with.
 
Upvote 0
please tell me the solution. programmed the app. I a m using the outpan database. all i need help with is when i scan the medicine product it prints the barcode or qr code scan to the outpan database search engine on its own. it scan takes me to the database and writes the search on its own. Then as i have been saying lets say i barcode or qr code scan a non medicine product it should print out invalid scan. that si all what i really need help with.

OK, so do you know if there's anything specific in the QRs or barcodes you want to scan, that specifically states or indicates that it's for a medicine or drug. and it's not something from a can of baked beans or packet of washing powder or whatever. Because if there isn't, you will require a database of all the drug codes that the app can check, and get an affirmative or negative response.

Supermarket checkout scanners effectively do something similar anyway, besides having a database of all the products with their prices, if one tries and scan something they don't sell it will come up as "not found" or "invalid".
 
Last edited:
Upvote 0
OK, so do you know if there's anything specific in the QRs or barcodes you want to scan, that specifically states or indicates that it's for a medicine or drug. and it's not something from a can of baked beans or packet of washing powder or whatever. Because if there isn't, you will require a database of all the drug codes that the app can check, and get an affirmative or negative response.
yEs medication product. OMG. I am been saying the same thing over and over again and i am not getting a relevant response. all I want is for my program to barcode or qr code any medication products. any medicines. after that it goes to the database outpan.com. I want it to automatically print the barcode number or qr code scan into there search engine and from there it gets saved to the databases. any other products that are not medication related should print out scan invalid. I just need to known the code for that. thats all.
 
Upvote 0
What answer are you seeking?
If you want to know if a barcode is for a tin of baked beans, or a container of paracetamol tablets, then nobody here knows the answer to that question.

People are asking you, is there anything in the barcode which indicates a medical product. If not, you will have to either access a database of known medical products, or compile your own.
 
Upvote 0
What answer are you seeking?
If you want to know if a barcode is for a tin of baked beans, or a container of paracetamol tablets, then nobody here knows the answer to that question.

Alright just give me all the databases for medication products. And at least tell me what code to use if I scan something that's not a medicine like let's say I scan a book which is not a medicine result should print invalid scan. At least help me with that. I will take care of the databases. Just give me the links to mainly medication databases.

People are asking you, is there anything in the barcode which indicates a medical product. If not, you will have to either access a database of known medical products, or compile your own.
 
Upvote 0
Alright just give me all the databases for medication products. And at least tell me what code to use if I scan something that's not a medicine like let's say I scan a book which is not a medicine result should print invalid scan. At least help me with that. I will take care of the databases. Just give me the links to mainly medication databases.
 
Upvote 0
The answer to the question of what medical product databases are available, is unlikely to be found here, because nobody seems to know off the top of their head. You could try asking that question on StackOverflow, which gets a much wider exposure, and someone there may know.

As for what code to use, well that depends on what database you will access. If you're providing your own database, then you must implement something like this

http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/

If you're using a publicly available third party database, then it will offer something like a REST interface, with a well defined API. The service should provide full documentation telling you how to use that API.
 
Upvote 0
This is in China, but medical products here do have a specific barcode type, which is a Code-128 20 digit number, that I've only seen on medicines and drugs. So if the code scanned doesn't comply, like it's an ordinary UPC or something, can assume it's not a medicine or drug, and flag it as invalid. Might be something similar in other countries as well.


This is definitely a medicine, and there's no code like this at all on Master Kong instant beef noodles or whatever.
salts.jpg
 
Last edited:
Upvote 0
Sure there isn't a global standard for this at all, what I showed is China only.

Think in the UK, certainly non-prescription medicines, just have an ordinary UPC code, which won't tell you anything unless you have the appropriate database. There's maybe a QR, which just takes you to be manufacturer's website or something.

Google has a UPC search feature in their barcode scanner app, which looks up what the product is, but then it's up to you to determine if it's a pharmaceutical product or not .
 
Last edited:
Upvote 0
Hi i am making a caregiver app and made modifications with the code. What I am trying to do is link buttons to a file. When i click the create button it should ask me how many lies to create and I should be able to name the files in the create button category. How do I program that? Then for scan i right now have it doing something temporarily different but when I click scan inside the scan button 3 button options should show up which are barcode, qrcode and image. How do i link those 3 buttons inside the scan button category? Thank you for your help.



import com.example.Caregiver.R;

import android.app.Activity;

import android.app.AlertDialog;

import android.content.ActivityNotFoundException;

import android.content.DialogInterface;

import android.content.Intent;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.drawable.Drawable;

import android.net.Uri;

import android.os.Bundle;

import android.provider.MediaStore;

import android.util.Log;

import android.view.Gravity;

import android.view.Menu;

import android.view.MenuInflater;

import android.view.MenuItem;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.ImageView;

import android.widget.TextView;

import android.widget.Toast;

import java.io.File;

import android.graphics.drawable.BitmapDrawable;

import android.graphics.drawable.Drawable;



public class MainActivity extends Activity {



static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;

static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";

private Uri fileUri;







@override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

@override

public boolean onCreateOptionsMenu(Menu menu) {

MenuInflater inflater = getMenuInflater();

inflater.inflate(R.menu.testmenu, menu);

return true;

}



@override

public boolean onOptionsItemSelected(MenuItem item){

super.onOptionsItemSelected(item);

switch(item.getItemId()){

case R.id.Create:

CreateMenuItem();

break;

case R.id.scan:

scanMenuItem();

break;

case R.id.View:

ViewMenuItem();

break;

}

return true;

}

private void CreateMenuItem(){

new AlertDialog.Builder(this)

.setTitle("Create")

.setMessage("This is a create dialog")

.setNeutralButton("OK", new DialogInterface.OnClickListener() {



@override

public void onClick(DialogInterface dialog, int which) {

// TODO Auto-generated method stub



}

}).show();

}



private void scanMenuItem(){

try{

Intent intent = new Intent(ACTION_SCAN);

intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

startActivityForResult(intent, 0);

}catch (ActivityNotFoundException e){

showDialog(MainActivity.this, "No Scanner Found",

"Download a scanner code activity?", "Yes", "No").show();

}

}



private void ViewMenuItem(){

new AlertDialog.Builder(this)

.setTitle("View")

.setMessage("This is a dialog")

.setNeutralButton("OK", new DialogInterface.OnClickListener() {



@override

public void onClick(DialogInterface dialog, int which) {

// TODO Auto-generated method stub



}

}).show();

}



public void scanBar(View v){

try{

Intent intent = new Intent(ACTION_SCAN);

intent.putExtra("SCAN_MODE", "PRODUCT_MODE");

startActivityForResult(intent, 0);

}catch (ActivityNotFoundException e){

showDialog(MainActivity.this, "No Scanner Found",

"Download a scanner code activity?", "Yes", "No").show();



}





}



public void scanQR(View v){

try{

Intent intent = new Intent(ACTION_SCAN);

intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

startActivityForResult(intent, 0);

}catch (ActivityNotFoundException e){

showDialog(MainActivity.this, "No Scanner Found",

"Download a scanner code activity?", "Yes", "No").show();

}

}



public void Camera(View v){

try{

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

//fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

}catch (ActivityNotFoundException e){



}

}



private static AlertDialog showDialog(final Activity act,

CharSequence title, CharSequence message,

CharSequence buttonYes,

CharSequence buttonNo) {



AlertDialog.Builder dowloadDialog = new AlertDialog.Builder(act);

dowloadDialog.setTitle(title).setMessage(message).setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {



@override

public void onClick(DialogInterface dialog, int which) {

Uri uri = Uri.parse("market://search?q=pname:" +

"com.google.zxing.client.android");



Intent intent = new Intent(Intent.ACTION_VIEW, uri);

try{

act.startActivity(intent);

} catch(ActivityNotFoundException e){



}



}

}).setNegativeButton(buttonNo, new DialogInterface.OnClickListener() {



@override

public void onClick(DialogInterface dialog, int which) {





}

});



return dowloadDialog.show();



}



protected void onActivityResult1(int requestCode, int resultCode, Intent data) {

if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {

if (resultCode == RESULT_OK) {

// Image captured and saved to fileUri specified in the Intent

Toast.makeText(this, "Image saved to:\n" +

data.getData(), Toast.LENGTH_LONG).show();

} else if (resultCode == RESULT_CANCELED) {

// User cancelled the image capture



} else {

// Image capture failed, advise user

}

}

}



@override

protected void onActivityResult(int requestCode, int resultCode, Intent intent){

if(requestCode == 0){

if(resultCode == RESULT_OK){

String contents = intent.getStringExtra("SCAN_RESULT");

String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

Toast.makeText(this, "Content:" + contents + "Format:" + format,

Toast.LENGTH_LONG).show();



} else if (resultCode == RESULT_CANCELED) {

// Handle cancel

Toast toast = Toast.makeText(this, "Scan was Cancelled!", Toast.LENGTH_LONG);

toast.setGravity(Gravity.TOP, 25, 400);

toast.show();



}

}

}

}

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/container"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#ffffff"

android:backgroundTint="@android:color/holo_blue_bright"

android:foregroundTint="@android:color/holo_red_light"

android:eek:rientation="vertical"

tools:context="com.javacodegeeks.androidstartactivityforresultexample.ActivityOne" >



<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center|top"

android:layout_margin="20dp"

android:text="Scan"

android:textColor="#000000"

android:textSize="30dp" />





<Button

android:id="@+id/scanner"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_purple"

android:gravity="center"

android:eek:nClick="Create"

android:text="Create"

android:textSize="18dp" />



<Button

android:id="@+id/scanner1"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_orange_dark"

android:gravity="center"

android:eek:nClick="scanQR"

android:text="Scan"

android:textSize="18dp" />









<!-- <Button -->

<!-- android:id="@+id/scanner1" -->

<!-- android:layout_width="250dp" -->

<!-- android:layout_height="80dp" -->

<!-- android:layout_gravity="center" -->

<!-- android:layout_margin="10dp" -->

<!-- android:backgroundTint="@android:color/holo_orange_dark" -->

<!-- android:gravity="center" -->

<!-- android:eek:nClick="scanQR" -->

<!-- android:text="QR Code" -->

<!-- android:textSize="18dp" /> -->







<!-- <Button -->

<!-- android:id="@+id/scanner2" -->

<!-- android:layout_width="250dp" -->

<!-- android:layout_height="80dp" -->

<!-- android:layout_gravity="center" -->

<!-- android:layout_margin="10dp" -->

<!-- android:backgroundTint="@android:color/holo_purple" -->

<!-- android:gravity="center" -->

<!-- android:eek:nClick="scanBar" -->

<!-- android:text="Bar Code" -->

<!-- android:textSize="18dp" /> -->







<Button

android:id="@+id/scanner2"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_red_dark"

android:gravity="center"

android:eek:nClick="Camera"

android:text="Image"

android:textSize="18dp" >



</Button>



<Button

android:id="@+id/scanner3"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_blue_dark"

android:gravity="center"

android:eek:nClick="View"

android:text="View"

android:textSize="18dp" >



</Button>







</LinearLayout>


testmenu:


<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item

android:id="@+id/Create"

android:title="Create"

android:eek:rderInCategory="1"

android:showAsAction="ifRoom"/>



<item

android:id="@+id/scan"

android:title="Scan"

android:eek:rderInCategory="2"

android:showAsAction="never"/>



<item

android:id="@+id/View"

android:title="View"

android:eek:rderInCategory="3"

android:showAsAction="never"/>





</menu>
 
Upvote 0
Hi i am making a caregiver app and made modifications with the code. What I am trying to do is link buttons to a file. When i click the create button it should ask me how many lies to create and I should be able to name the files in the create button category. How do I program that? Then for scan i right now have it doing something temporarily different but when I click scan inside the scan button 3 button options should show up which are barcode, qrcode and image. How do i link those 3 buttons inside the scan button category? Thank you for your help.


Code:
 import com.example.Caregiver.R;

import android.app.Activity;

import android.app.AlertDialog;

import android.content.ActivityNotFoundException;

import android.content.DialogInterface;

import android.content.Intent;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.drawable.Drawable;

import android.net.Uri;

import android.os.Bundle;

import android.provider.MediaStore;

import android.util.Log;

import android.view.Gravity;

import android.view.Menu;

import android.view.MenuInflater;

import android.view.MenuItem;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.ImageView;

import android.widget.TextView;

import android.widget.Toast;

import java.io.File;

import android.graphics.drawable.BitmapDrawable;

import android.graphics.drawable.Drawable; 



public class MainActivity extends Activity {



static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; 

static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";

private Uri fileUri;







@override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

@override

public boolean onCreateOptionsMenu(Menu menu) {

MenuInflater inflater = getMenuInflater();

inflater.inflate(R.menu.testmenu, menu);

return true;

}



@override

public boolean onOptionsItemSelected(MenuItem item){

super.onOptionsItemSelected(item);

switch(item.getItemId()){

case R.id.Create:

CreateMenuItem();

break;

case R.id.scan:

scanMenuItem();

break;

case R.id.View:

ViewMenuItem();

break;

}

return true;

}

private void CreateMenuItem(){

new AlertDialog.Builder(this)

.setTitle("Create")

.setMessage("This is a create dialog")

.setNeutralButton("OK", new DialogInterface.OnClickListener() {



@override

public void onClick(DialogInterface dialog, int which) {

// TODO Auto-generated method stub



}

}).show();

}



private void scanMenuItem(){

try{

Intent intent = new Intent(ACTION_SCAN);

intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

startActivityForResult(intent, 0);

}catch (ActivityNotFoundException e){

showDialog(MainActivity.this, "No Scanner Found", 

"Download a scanner code activity?", "Yes", "No").show();

}

}



private void ViewMenuItem(){

new AlertDialog.Builder(this)

.setTitle("View")

.setMessage("This is a dialog")

.setNeutralButton("OK", new DialogInterface.OnClickListener() {



@override

public void onClick(DialogInterface dialog, int which) {

// TODO Auto-generated method stub



}

}).show();

}



public void scanBar(View v){

try{

Intent intent = new Intent(ACTION_SCAN);

intent.putExtra("SCAN_MODE", "PRODUCT_MODE");

startActivityForResult(intent, 0);

}catch (ActivityNotFoundException e){

showDialog(MainActivity.this, "No Scanner Found", 

"Download a scanner code activity?", "Yes", "No").show();



}





}



public void scanQR(View v){

try{

Intent intent = new Intent(ACTION_SCAN);

intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

startActivityForResult(intent, 0);

}catch (ActivityNotFoundException e){

showDialog(MainActivity.this, "No Scanner Found", 

"Download a scanner code activity?", "Yes", "No").show();

}

} 



public void Camera(View v){

try{

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

//fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

}catch (ActivityNotFoundException e){



}

}



private static AlertDialog showDialog(final Activity act,

CharSequence title, CharSequence message, 

CharSequence buttonYes,

CharSequence buttonNo) {



AlertDialog.Builder dowloadDialog = new AlertDialog.Builder(act);

dowloadDialog.setTitle(title).setMessage(message).setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {



@override

public void onClick(DialogInterface dialog, int which) {

Uri uri = Uri.parse("market://search?q=pname:" +

"com.google.zxing.client.android");



Intent intent = new Intent(Intent.ACTION_VIEW, uri);

try{

act.startActivity(intent);

} catch(ActivityNotFoundException e){



}



}

}).setNegativeButton(buttonNo, new DialogInterface.OnClickListener() {



@override

public void onClick(DialogInterface dialog, int which) {





}

});



return dowloadDialog.show();



}



protected void onActivityResult1(int requestCode, int resultCode, Intent data) {

if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {

if (resultCode == RESULT_OK) {

// Image captured and saved to fileUri specified in the Intent

Toast.makeText(this, "Image saved to:\n" +

data.getData(), Toast.LENGTH_LONG).show();

} else if (resultCode == RESULT_CANCELED) {

// User cancelled the image capture



} else {

// Image capture failed, advise user

}

}

}



@override

protected void onActivityResult(int requestCode, int resultCode, Intent intent){

if(requestCode == 0){

if(resultCode == RESULT_OK){

String contents = intent.getStringExtra("SCAN_RESULT");

String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

Toast.makeText(this, "Content:" + contents + "Format:" + format,

Toast.LENGTH_LONG).show();



} else if (resultCode == RESULT_CANCELED) {

// Handle cancel

Toast toast = Toast.makeText(this, "Scan was Cancelled!", Toast.LENGTH_LONG);

toast.setGravity(Gravity.TOP, 25, 400);

toast.show();



}

}

}

}

activity_main.xml:

Code:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/container"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#ffffff"

android:backgroundTint="@android:color/holo_blue_bright"

android:foregroundTint="@android:color/holo_red_light"

android:eek:rientation="vertical"

tools:context="com.javacodegeeks.androidstartactivityforresultexample.ActivityOne" >



<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center|top"

android:layout_margin="20dp"

android:text="Scan"

android:textColor="#000000"

android:textSize="30dp" />





<Button

android:id="@+id/scanner"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_purple"

android:gravity="center"

android:eek:nClick="Create"

android:text="Create"

android:textSize="18dp" />



<Button

android:id="@+id/scanner1"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_orange_dark"

android:gravity="center"

android:eek:nClick="scanQR"

android:text="Scan"

android:textSize="18dp" />









<!-- <Button -->

<!-- android:id="@+id/scanner1" -->

<!-- android:layout_width="250dp" -->

<!-- android:layout_height="80dp" -->

<!-- android:layout_gravity="center" -->

<!-- android:layout_margin="10dp" -->

<!-- android:backgroundTint="@android:color/holo_orange_dark" -->

<!-- android:gravity="center" -->

<!-- android:eek:nClick="scanQR" -->

<!-- android:text="QR Code" -->

<!-- android:textSize="18dp" /> -->







<!-- <Button -->

<!-- android:id="@+id/scanner2" -->

<!-- android:layout_width="250dp" -->

<!-- android:layout_height="80dp" -->

<!-- android:layout_gravity="center" -->

<!-- android:layout_margin="10dp" -->

<!-- android:backgroundTint="@android:color/holo_purple" -->

<!-- android:gravity="center" -->

<!-- android:eek:nClick="scanBar" -->

<!-- android:text="Bar Code" -->

<!-- android:textSize="18dp" /> -->







<Button

android:id="@+id/scanner2"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_red_dark"

android:gravity="center"

android:eek:nClick="Camera"

android:text="Image"

android:textSize="18dp" >



</Button>



<Button

android:id="@+id/scanner3"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_blue_dark"

android:gravity="center"

android:eek:nClick="View"

android:text="View"

android:textSize="18dp" >



</Button>
</LinearLayout>


testmenu:


Code:
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item 

android:id="@+id/Create"

android:title="Create"

android:eek:rderInCategory="1"

android:showAsAction="ifRoom"/>



<item 

android:id="@+id/scan"

android:title="Scan" 

android:eek:rderInCategory="2"

android:showAsAction="never"/>



<item 

android:id="@+id/View"

android:title="View" 

android:eek:rderInCategory="3"

android:showAsAction="never"/>
</menu>
 
Upvote 0
Still not looking that readable though is it? No indentation, and too many line spaces.
listen i'll fix the indentation and line spaces for next time but can i please get a chance to learn about the question I asked. This is a very important pr
Still not looking that readable though is it? No indentation, and too many line spaces.
Hey i understand the spaces but i did the forum the way you said. Can i just please get help on my question i asked. thats all i need. I'm actually still new to this site.
my question: Hi i am making a caregiver app and made modifications with the code. What I am trying to do is link buttons to a file. When i click the create button it should ask me how many lies to create and I should be able to name the files in the create button category. How do I program that? Then for scan i right now have it doing something temporarily different but when I click scan inside the scan button 3 button options should show up which are barcode, qrcode and image. How do i link those 3 buttons inside the scan button category? Thank you for your help.
Thanks i promise next time when i paste my code its more indented and readable.
 
Upvote 0
Unfortunately your question is very broad, covering a wide selection of issues. On most technical Q&A forums it would be closed as too broad. This is because it's unclear what specifically you're asking, or the questions are so numerous that it would take respondents a lot of time to answer, and nobody is going to write blocks of code for you.
So it's reasonable to ask that you provide some code to work with, and also provide that code in a format which people can read and understand easily. Otherwise you're unlikely to get any answers.

When i click the create button it should ask me how many lies to create and I should be able to name the files in the create button category

So for this you will need to create a Dialog in your button click listener

https://developer.android.com/guide/topics/ui/dialogs.html

Then for scan i right now have it doing something temporarily different but when I click scan inside the scan button 3 button options should show up which are barcode, qrcode and image. How do i link those 3 buttons inside the scan button category?

I appreciate that English is probably not your first language, but this question doesn't make much sense. You might want to consider re-phrasing it.
And if you're referring to the code you posted, then it's important to make that code readable.
 
Last edited by a moderator:
Upvote 0
Hi I'm actually trying to write a app for my app that involves creating files. it works great but i need help as in when i click the create button and it takes me to create a file how do i make it create the file in my app. when i click on create file how do I make it create a file folder inside the app. along with that when i want to save a file from barcode scan, qrcode scan or image how do i program the savein button for whichever folder i want to save my scan into. how do i make sure i can make multiple folders in the app so when i scan or take picture i can save it into whichever file category i want. Thank you.

Here is my code:

Code:
package com.example.Caregiver;
import com.example.Caregiver.R;

import android.app.Activity;

import android.app.AlertDialog;

import android.content.ActivityNotFoundException;

import android.content.DialogInterface;

import android.content.Intent;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.drawable.Drawable;

import android.net.Uri;

import android.os.Bundle;

import android.provider.MediaStore;

import android.util.Log;

import android.view.Gravity;

import android.view.Menu;

import android.view.MenuInflater;

import android.view.MenuItem;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.ImageView;

import android.widget.TextView;

import android.widget.Toast;

import java.io.File;

import android.graphics.drawable.BitmapDrawable;

import android.graphics.drawable.Drawable; 



public class MainActivity extends Activity  {

   

static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;     

static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";

private Uri fileUri;







@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Button button1 = (Button) findViewById(R.id.scanner);



button1.setOnClickListener(new OnClickListener(){



     

    public void onClick(View v) {

        Intent i = new Intent(MainActivity.this, Create.class);

        startActivity(i);

    }

    });



Button button2 = (Button) findViewById(R.id.scanner2);



button2.setOnClickListener(new OnClickListener(){



     

    public void onClick(View v) {

        Intent i = new Intent(MainActivity.this, First.class);

        startActivity(i);

    }

    });





Button button3 = (Button) findViewById(R.id.scanner3);



button3.setOnClickListener(new OnClickListener(){



     

    public void onClick(View v) {

        Intent i = new Intent(MainActivity.this, ViewOption.class);

        startActivity(i);

    }

    });



}



@Override

public boolean onCreateOptionsMenu(Menu menu) {

    MenuInflater inflater = getMenuInflater();

    inflater.inflate(R.menu.testmenu, menu);

    return true;

}



@Override

public boolean onOptionsItemSelected(MenuItem item){

    super.onOptionsItemSelected(item);

    switch(item.getItemId()){

    case R.id.Create:

        CreateMenuItem();

        break;

    case R.id.scan1:

        scanMenuItem();

        break;

    case R.id.View:

        ViewMenuItem();

        break;

    }

    return true;

    }

private void CreateMenuItem(){

    new AlertDialog.Builder(this)

    .setTitle("Create")

    .setMessage("This is a create dialog")

    .setNeutralButton("OK", new DialogInterface.OnClickListener() {

       

        @Override

        public void onClick(DialogInterface dialog, int which) {

            // TODO Auto-generated method stub

           

        }

    }).show();

}



private void scanMenuItem(){

    setContentView(R.layout.activity_main);

    Button button4 = (Button) findViewById(R.id.scan1);



    button4.setOnClickListener(new OnClickListener(){



         

        public void onClick(View v) {

            Intent i = new Intent(MainActivity.this, ScanOptions.class);

            startActivity(i);

        }

        });



    }

   

private void ViewMenuItem(){

    new AlertDialog.Builder(this)

    .setTitle("View")

    .setMessage("This is a dialog")

    .setNeutralButton("OK", new DialogInterface.OnClickListener() {

       

        @Override

        public void onClick(DialogInterface dialog, int which) {

            // TODO Auto-generated method stub

           

        }

    }).show();

}





}

Code:
import java.io.FileOutputStream;
import java.io.IOException;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.view.MenuItem;

public class File extends Activity {
   
    public File getTempFile(Context context, String url) {
       
       File file;
       String fileName = Uri.parse(url).getLastPathSegment();
       
        file = File.createTempFile(fileName, null, context.getCacheDir());
       

       return file;
       
    }

    private static File createTempFile(String fileName, Object object, java.io.File cacheDir) {
        // TODO Auto-generated method stub
        return null;
    }

    /* Checks if external storage is available for read and write */
    public boolean isExternalStorageWritable() {
       String state = Environment.getExternalStorageState();
       if (Environment.MEDIA_MOUNTED.equals(state)) {
           return true;
       }
       return false;
    }

    /* Checks if external storage is available to at least read */
    public boolean isExternalStorageReadable() {
       String state = Environment.getExternalStorageState();
       if (Environment.MEDIA_MOUNTED.equals(state) ||
           Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
           return true;
       }
       return false;
    }

}


import java.io.FileOutputStream;
import java.io.IOException;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.view.MenuItem;

public class File extends Activity {
   
    public File getTempFile(Context context, String url) {
       
       File file;
       String fileName = Uri.parse(url).getLastPathSegment();
       
        file = File.createTempFile(fileName, null, context.getCacheDir());
       

       return file;
       
    }

    private static File createTempFile(String fileName, Object object, java.io.File cacheDir) {
        // TODO Auto-generated method stub
        return null;
    }

    /* Checks if external storage is available for read and write */
    public boolean isExternalStorageWritable() {
       String state = Environment.getExternalStorageState();
       if (Environment.MEDIA_MOUNTED.equals(state)) {
           return true;
       }
       return false;
    }

    /* Checks if external storage is available to at least read */
    public boolean isExternalStorageReadable() {
       String state = Environment.getExternalStorageState();
       if (Environment.MEDIA_MOUNTED.equals(state) ||
           Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
           return true;
       }
       return false;
    }

}



Code:
public class First extends Activity {



    static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;     

    static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";

    private Uri fileUri;

   

   

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_first);

    }



    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.first, menu);

        return true;

    }



    @Override

    public boolean onOptionsItemSelected(MenuItem item) {

        // Handle action bar item clicks here. The action bar will

        // automatically handle clicks on the Home/Up button, so long

        // as you specify a parent activity in AndroidManifest.xml.

        int id = item.getItemId();

        if (id == R.id.action_settings) {

            return true;

        }

        return super.onOptionsItemSelected(item);

    }







    public void BarCode(View v){

        try{

            Intent intent = new Intent(ACTION_SCAN);

            intent.putExtra("SCAN_MODE", "PRODUCT_MODE");

            startActivityForResult(intent, 0);

        }catch (ActivityNotFoundException e){

            showDialog(First.this, "No Scanner Found", 

        "Download a scanner code activity?", "Yes", "No").show();

   

    }

       

       

    }

   

    public void QRCode(View v){

        try{

            Intent intent = new Intent(ACTION_SCAN);

            intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

            startActivityForResult(intent, 0);

        }catch (ActivityNotFoundException e){

            showDialog(First.this, "No Scanner Found", 

    "Download a scanner code activity?", "Yes", "No").show();

        }

    } 

   

    public void Camera(View v){

        try{

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

        //fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

        startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

        }catch (ActivityNotFoundException e){

             

        }

    }



    private static AlertDialog showDialog(final Activity act,

            CharSequence title, CharSequence message, 

            CharSequence buttonYes,

            CharSequence buttonNo) {

       

    AlertDialog.Builder dowloadDialog = new AlertDialog.Builder(act);

    dowloadDialog.setTitle(title).setMessage(message).setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {

           

            @Override

            public void onClick(DialogInterface dialog, int which) {

                Uri uri = Uri.parse("market://search?q=pname:" +

            "com.google.zxing.client.android");

               

                Intent intent = new Intent(Intent.ACTION_VIEW, uri);

                try{

                    act.startActivity(intent);

                } catch(ActivityNotFoundException e){

       

                }

               

            }

}).setNegativeButton(buttonNo, new DialogInterface.OnClickListener() {

           

            @Override

            public void onClick(DialogInterface dialog, int which) {

                 

               

            }

        });

       

        return dowloadDialog.show();

       

    }

   

    protected void onActivityResult1(int requestCode, int resultCode, Intent data) {

        if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {

            if (resultCode == RESULT_OK) {

                // Image captured and saved to fileUri specified in the Intent

                Toast.makeText(this, "Image saved to:\n" +

                        data.getData(), Toast.LENGTH_LONG).show();

            } else if (resultCode == RESULT_CANCELED) {

                // User cancelled the image capture

               

            } else {

                // Image capture failed, advise user

            }

        }

    }

   

    @Override

    protected void onActivityResult(int requestCode, int resultCode, Intent intent){

        if(requestCode == 0){

            if(resultCode == RESULT_OK){

                String contents = intent.getStringExtra("SCAN_RESULT");

                String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

                String apioutpan = "https://api.outpan.com/v2/products/" + contents+ "?apikey=139c8752bc1213a618d987b8195422d3";  

                Toast.makeText(this, "Content:" + contents + "Format:" + format,

                        Toast.LENGTH_LONG).show();

                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(apioutpan));



                startActivity(browserIntent);

                 

            } else if (resultCode == RESULT_CANCELED) {

                // Handle cancel

                Toast toast = Toast.makeText(this, "Scan was Cancelled!", Toast.LENGTH_LONG);

                toast.setGravity(Gravity.TOP, 25, 400);

                toast.show();

               

            }

        }

    }

}


Code:
import android.app.Activity;

import android.app.AlertDialog;

import android.content.ActivityNotFoundException;

import android.content.DialogInterface;

import android.content.Intent;

import android.net.Uri;

import android.os.Bundle;

import android.provider.MediaStore;

import android.view.Gravity;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.widget.Toast;



public class ScanOptions extends Activity {

    static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;     

    static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";

    private Uri fileUri;





    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_scan_options);

    }



    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.scan_options, menu);

        return true;

    }



    @Override

    public boolean onOptionsItemSelected(MenuItem item) {

        // Handle action bar item clicks here. The action bar will

        // automatically handle clicks on the Home/Up button, so long

        // as you specify a parent activity in AndroidManifest.xml.

        int id = item.getItemId();

        if (id == R.id.action_settings) {

            return true;

        }

        return super.onOptionsItemSelected(item);

    }





        public void BarCode(View v){

            try{

                Intent intent = new Intent(ACTION_SCAN);

                intent.putExtra("SCAN_MODE", "PRODUCT_MODE");

                startActivityForResult(intent, 0);

            }catch (ActivityNotFoundException e){

                showDialog(ScanOptions.this, "No Scanner Found", 

            "Download a scanner code activity?", "Yes", "No").show();

       

        }

           

           

        }

       

        public void QRCode(View v){

            try{

                Intent intent = new Intent(ACTION_SCAN);

                intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

                startActivityForResult(intent, 0);

            }catch (ActivityNotFoundException e){

                showDialog(ScanOptions.this, "No Scanner Found", 

        "Download a scanner code activity?", "Yes", "No").show();

            }

        } 

       

        public void Camera(View v){

            try{

            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

            //fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

            startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

            }catch (ActivityNotFoundException e){

                 

            }

        }



        private static AlertDialog showDialog(final Activity act,

                CharSequence title, CharSequence message, 

                CharSequence buttonYes,

                CharSequence buttonNo) {

           

        AlertDialog.Builder dowloadDialog = new AlertDialog.Builder(act);

        dowloadDialog.setTitle(title).setMessage(message).setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {

               

                @Override

                public void onClick(DialogInterface dialog, int which) {

                    Uri uri = Uri.parse("market://search?q=pname:" +

                "com.google.zxing.client.android");

                   

                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);

                    try{

                        act.startActivity(intent);

                    } catch(ActivityNotFoundException e){

           

                    }

                   

                }

    }).setNegativeButton(buttonNo, new DialogInterface.OnClickListener() {

               

                @Override

                public void onClick(DialogInterface dialog, int which) {

                     

                   

                }

            });

           

            return dowloadDialog.show();

           

        }

       

        protected void onActivityResult1(int requestCode, int resultCode, Intent data) {

            if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {

                if (resultCode == RESULT_OK) {

                    // Image captured and saved to fileUri specified in the Intent

                    Toast.makeText(this, "Image saved to:\n" +

                            data.getData(), Toast.LENGTH_LONG).show();

                } else if (resultCode == RESULT_CANCELED) {

                    // User cancelled the image capture

                   

                } else {

                    // Image capture failed, advise user

                }

            }

        }

       

        @Override

        protected void onActivityResult(int requestCode, int resultCode, Intent intent){

            if(requestCode == 0){

                if(resultCode == RESULT_OK){

                    String contents = intent.getStringExtra("SCAN_RESULT");

                    String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

                    Toast.makeText(this, "Content:" + contents + "Format:" + format,

                            Toast.LENGTH_LONG).show();

                     

                } else if (resultCode == RESULT_CANCELED) {

                    // Handle cancel

                    Toast toast = Toast.makeText(this, "Scan was Cancelled!", Toast.LENGTH_LONG);

                    toast.setGravity(Gravity.TOP, 25, 400);

                    toast.show();

                   

                }

            }

        }

    }


Code:
import android.app.Activity;

import android.app.AlertDialog;

import android.content.ActivityNotFoundException;

import android.content.DialogInterface;

import android.content.Intent;

import android.net.Uri;

import android.os.Bundle;

import android.provider.MediaStore;

import android.view.Gravity;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.widget.Toast;



public class ViewOption extends Activity {



    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_view_option);

    }



    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.view_option, menu);

        return true;

    }



    @Override

    public boolean onOptionsItemSelected(MenuItem item) {

        // Handle action bar item clicks here. The action bar will

        // automatically handle clicks on the Home/Up button, so long

        // as you specify a parent activity in AndroidManifest.xml.

        int id = item.getItemId();

        if (id == R.id.action_settings) {

            return true;

        }

        return super.onOptionsItemSelected(item);

    }

}

Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context="{relativePackage}.${activityClass}" >



    <TextView

        android:id="@+id/textView1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentRight="true"

        android:background="#008080"

        android:padding="5dp"

        android:text="Android Read and Write Text form File"

        android:textColor="#fff" />



    <EditText

        android:id="@+id/editText1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentRight="true"

        android:layout_below="@+id/textView1"

        android:layout_marginTop="22dp"

        android:ems="10" 

        android:layout_margin="5dp">

        <requestFocus />

    </EditText>



    <Button

        android:id="@+id/button1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentRight="true"

        android:layout_below="@+id/editText1"

        android:text="Write Text into File"

        android:onClick="WriteBtn" 

        android:layout_margin="5dp"/>

   

    <Button

        android:id="@+id/button2"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentRight="true"

        android:layout_below="@+id/button1"

        android:text="Read Text From file"

        android:onClick="ReadBtn"

        android:layout_margin="5dp" />

   

</RelativeLayout>

Code:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/container"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:background="#ffffff"

    android:backgroundTint="@android:color/holo_blue_bright"

    android:foregroundTint="@android:color/holo_red_light"

    android:orientation="vertical"

    tools:context="com.example.Caregiver.First" >



    <TextView

        android:id="@+id/textView1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_gravity="center|top"

        android:layout_margin="20dp"

        android:text="Scan Options"

        android:textColor="#000000"

        android:textSize="30dp" />



    <Button

        android:id="@+id/BarCode"

        android:layout_width="match_parent"

        android:layout_height="64dp"

        android:layout_margin="10dp"

        android:backgroundTint="@android:color/holo_orange_dark"

        android:gravity="center"

        android:onClick="BarCode"

        android:text="BarCode"

        android:textSize="18dp" />

   

    <Button

        android:id="@+id/scanner5"

        android:layout_width="match_parent"

        android:layout_height="75dp"

        android:layout_gravity="center"

        android:layout_margin="10dp"

        android:backgroundTint="@android:color/holo_red_dark"

        android:gravity="center"

        android:onClick="Camera"

        android:text="Image"

        android:textSize="18dp" >



</Button>



    <Button

        android:id="@+id/QRCode"

        android:layout_width="match_parent"

        android:layout_height="64dp"

        android:layout_margin="10dp"

        android:layout_marginTop="14dp"

        android:backgroundTint="@android:color/holo_orange_dark"

        android:gravity="center"

        android:onClick="QRCode"

        android:text="QRCode"

        android:textSize="18dp" />



</LinearLayout>

Code:
package com.example.Caregiver;
import com.example.Caregiver.R;

import android.app.Activity;

import android.app.AlertDialog;

import android.content.ActivityNotFoundException;

import android.content.DialogInterface;

import android.content.Intent;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.drawable.Drawable;

import android.net.Uri;

import android.os.Bundle;

import android.provider.MediaStore;

import android.util.Log;

import android.view.Gravity;

import android.view.Menu;

import android.view.MenuInflater;

import android.view.MenuItem;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.ImageView;

import android.widget.TextView;

import android.widget.Toast;

import java.io.File;

import android.graphics.drawable.BitmapDrawable;

import android.graphics.drawable.Drawable; 



public class MainActivity extends Activity  {

    

static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;     

static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";

private Uri fileUri;







@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Button button1 = (Button) findViewById(R.id.scanner);



button1.setOnClickListener(new OnClickListener(){



     

    public void onClick(View v) {

        Intent i = new Intent(MainActivity.this, Create.class);

        startActivity(i);

    }

    });



Button button2 = (Button) findViewById(R.id.scanner2);



button2.setOnClickListener(new OnClickListener(){



     

    public void onClick(View v) {

        Intent i = new Intent(MainActivity.this, First.class);

        startActivity(i);

    }

    });





Button button3 = (Button) findViewById(R.id.scanner3);



button3.setOnClickListener(new OnClickListener(){



     

    public void onClick(View v) {

        Intent i = new Intent(MainActivity.this, ViewOption.class);

        startActivity(i);

    }

    });



}



@Override

public boolean onCreateOptionsMenu(Menu menu) {

    MenuInflater inflater = getMenuInflater();

    inflater.inflate(R.menu.testmenu, menu);

    return true;

}



@Override

public boolean onOptionsItemSelected(MenuItem item){

    super.onOptionsItemSelected(item);

    switch(item.getItemId()){

    case R.id.Create:

        CreateMenuItem();

        break;

    case R.id.scan1:

        scanMenuItem();

        break;

    case R.id.View:

        ViewMenuItem();

        break;

    }

    return true;

    }

private void CreateMenuItem(){

    new AlertDialog.Builder(this)

    .setTitle("Create")

    .setMessage("This is a create dialog")

    .setNeutralButton("OK", new DialogInterface.OnClickListener() {

        

        @Override

        public void onClick(DialogInterface dialog, int which) {

            // TODO Auto-generated method stub

            

        }

    }).show();

}



private void scanMenuItem(){

    setContentView(R.layout.activity_main);

    Button button4 = (Button) findViewById(R.id.scan1);



    button4.setOnClickListener(new OnClickListener(){



         

        public void onClick(View v) {

            Intent i = new Intent(MainActivity.this, ScanOptions.class);

            startActivity(i);

        }

        });



    }

    

private void ViewMenuItem(){

    new AlertDialog.Builder(this)

    .setTitle("View")

    .setMessage("This is a dialog")

    .setNeutralButton("OK", new DialogInterface.OnClickListener() {

        

        @Override

        public void onClick(DialogInterface dialog, int which) {

            // TODO Auto-generated method stub

            

        }

    }).show();

}





}

Code:
import java.io.FileOutputStream;
import java.io.IOException;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.view.MenuItem;

public class File extends Activity {
    
    public File getTempFile(Context context, String url) {
        
       File file;
       String fileName = Uri.parse(url).getLastPathSegment();
       
        file = File.createTempFile(fileName, null, context.getCacheDir());
        

       return file;
       
    }

    private static File createTempFile(String fileName, Object object, java.io.File cacheDir) {
        // TODO Auto-generated method stub
        return null;
    }

    /* Checks if external storage is available for read and write */
    public boolean isExternalStorageWritable() {
       String state = Environment.getExternalStorageState();
       if (Environment.MEDIA_MOUNTED.equals(state)) {
           return true;
       }
       return false;
    }

    /* Checks if external storage is available to at least read */
    public boolean isExternalStorageReadable() {
       String state = Environment.getExternalStorageState();
       if (Environment.MEDIA_MOUNTED.equals(state) ||
           Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
           return true;
       }
       return false;
    }

}


import java.io.FileOutputStream;
import java.io.IOException;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.view.MenuItem;

public class File extends Activity {
    
    public File getTempFile(Context context, String url) {
        
       File file;
       String fileName = Uri.parse(url).getLastPathSegment();
       
        file = File.createTempFile(fileName, null, context.getCacheDir());
        

       return file;
       
    }

    private static File createTempFile(String fileName, Object object, java.io.File cacheDir) {
        // TODO Auto-generated method stub
        return null;
    }

    /* Checks if external storage is available for read and write */
    public boolean isExternalStorageWritable() {
       String state = Environment.getExternalStorageState();
       if (Environment.MEDIA_MOUNTED.equals(state)) {
           return true;
       }
       return false;
    }

    /* Checks if external storage is available to at least read */
    public boolean isExternalStorageReadable() {
       String state = Environment.getExternalStorageState();
       if (Environment.MEDIA_MOUNTED.equals(state) ||
           Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
           return true;
       }
       return false;
    }

}



Code:
public class First extends Activity {



    static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;     

    static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";

    private Uri fileUri;

    

    

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_first);

    }



    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.first, menu);

        return true;

    }



    @Override

    public boolean onOptionsItemSelected(MenuItem item) {

        // Handle action bar item clicks here. The action bar will

        // automatically handle clicks on the Home/Up button, so long

        // as you specify a parent activity in AndroidManifest.xml.

        int id = item.getItemId();

        if (id == R.id.action_settings) {

            return true;

        }

        return super.onOptionsItemSelected(item);

    }







    public void BarCode(View v){

        try{

            Intent intent = new Intent(ACTION_SCAN);

            intent.putExtra("SCAN_MODE", "PRODUCT_MODE");

            startActivityForResult(intent, 0);

        }catch (ActivityNotFoundException e){

            showDialog(First.this, "No Scanner Found", 

        "Download a scanner code activity?", "Yes", "No").show();

    

    }

        

        

    }

    

    public void QRCode(View v){

        try{

            Intent intent = new Intent(ACTION_SCAN);

            intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

            startActivityForResult(intent, 0);

        }catch (ActivityNotFoundException e){

            showDialog(First.this, "No Scanner Found", 

    "Download a scanner code activity?", "Yes", "No").show();

        }

    } 

    

    public void Camera(View v){

        try{

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

        //fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

        startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

        }catch (ActivityNotFoundException e){

             

        }

    }



    private static AlertDialog showDialog(final Activity act,

            CharSequence title, CharSequence message, 

            CharSequence buttonYes,

            CharSequence buttonNo) {

        

    AlertDialog.Builder dowloadDialog = new AlertDialog.Builder(act);

    dowloadDialog.setTitle(title).setMessage(message).setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {

            

            @Override

            public void onClick(DialogInterface dialog, int which) {

                Uri uri = Uri.parse("market://search?q=pname:" +

            "com.google.zxing.client.android");

                

                Intent intent = new Intent(Intent.ACTION_VIEW, uri);

                try{

                    act.startActivity(intent);

                } catch(ActivityNotFoundException e){

        

                }

                

            }

}).setNegativeButton(buttonNo, new DialogInterface.OnClickListener() {

            

            @Override

            public void onClick(DialogInterface dialog, int which) {

                 

                

            }

        });

        

        return dowloadDialog.show();

        

    }

    

    protected void onActivityResult1(int requestCode, int resultCode, Intent data) {

        if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {

            if (resultCode == RESULT_OK) {

                // Image captured and saved to fileUri specified in the Intent

                Toast.makeText(this, "Image saved to:\n" +

                        data.getData(), Toast.LENGTH_LONG).show();

            } else if (resultCode == RESULT_CANCELED) {

                // User cancelled the image capture

               

            } else {

                // Image capture failed, advise user

            }

        }

    }

    

    @Override

    protected void onActivityResult(int requestCode, int resultCode, Intent intent){

        if(requestCode == 0){

            if(resultCode == RESULT_OK){

                String contents = intent.getStringExtra("SCAN_RESULT");

                String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

                String apioutpan = "https://api.outpan.com/v2/products/" + contents+ "?apikey=139c8752bc1213a618d987b8195422d3";  

                Toast.makeText(this, "Content:" + contents + "Format:" + format,

                        Toast.LENGTH_LONG).show();

                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(apioutpan));



                startActivity(browserIntent);

                 

            } else if (resultCode == RESULT_CANCELED) {

                // Handle cancel

                Toast toast = Toast.makeText(this, "Scan was Cancelled!", Toast.LENGTH_LONG);

                toast.setGravity(Gravity.TOP, 25, 400);

                toast.show();

               

            }

        }

    }

}


Code:
import android.app.Activity;

import android.app.AlertDialog;

import android.content.ActivityNotFoundException;

import android.content.DialogInterface;

import android.content.Intent;

import android.net.Uri;

import android.os.Bundle;

import android.provider.MediaStore;

import android.view.Gravity;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.widget.Toast;



public class ScanOptions extends Activity {

    static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;     

    static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";

    private Uri fileUri;





    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_scan_options);

    }



    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.scan_options, menu);

        return true;

    }



    @Override

    public boolean onOptionsItemSelected(MenuItem item) {

        // Handle action bar item clicks here. The action bar will

        // automatically handle clicks on the Home/Up button, so long

        // as you specify a parent activity in AndroidManifest.xml.

        int id = item.getItemId();

        if (id == R.id.action_settings) {

            return true;

        }

        return super.onOptionsItemSelected(item);

    }





        public void BarCode(View v){

            try{

                Intent intent = new Intent(ACTION_SCAN);

                intent.putExtra("SCAN_MODE", "PRODUCT_MODE");

                startActivityForResult(intent, 0);

            }catch (ActivityNotFoundException e){

                showDialog(ScanOptions.this, "No Scanner Found", 

            "Download a scanner code activity?", "Yes", "No").show();

        

        }

            

            

        }

        

        public void QRCode(View v){

            try{

                Intent intent = new Intent(ACTION_SCAN);

                intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

                startActivityForResult(intent, 0);

            }catch (ActivityNotFoundException e){

                showDialog(ScanOptions.this, "No Scanner Found", 

        "Download a scanner code activity?", "Yes", "No").show();

            }

        } 

        

        public void Camera(View v){

            try{

            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

            //fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

            startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

            }catch (ActivityNotFoundException e){

                 

            }

        }



        private static AlertDialog showDialog(final Activity act,

                CharSequence title, CharSequence message, 

                CharSequence buttonYes,

                CharSequence buttonNo) {

            

        AlertDialog.Builder dowloadDialog = new AlertDialog.Builder(act);

        dowloadDialog.setTitle(title).setMessage(message).setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {

                

                @Override

                public void onClick(DialogInterface dialog, int which) {

                    Uri uri = Uri.parse("market://search?q=pname:" +

                "com.google.zxing.client.android");

                    

                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);

                    try{

                        act.startActivity(intent);

                    } catch(ActivityNotFoundException e){

            

                    }

                    

                }

    }).setNegativeButton(buttonNo, new DialogInterface.OnClickListener() {

                

                @Override

                public void onClick(DialogInterface dialog, int which) {

                     

                    

                }

            });

            

            return dowloadDialog.show();

            

        }

        

        protected void onActivityResult1(int requestCode, int resultCode, Intent data) {

            if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {

                if (resultCode == RESULT_OK) {

                    // Image captured and saved to fileUri specified in the Intent

                    Toast.makeText(this, "Image saved to:\n" +

                            data.getData(), Toast.LENGTH_LONG).show();

                } else if (resultCode == RESULT_CANCELED) {

                    // User cancelled the image capture

                   

                } else {

                    // Image capture failed, advise user

                }

            }

        }

        

        @Override

        protected void onActivityResult(int requestCode, int resultCode, Intent intent){

            if(requestCode == 0){

                if(resultCode == RESULT_OK){

                    String contents = intent.getStringExtra("SCAN_RESULT");

                    String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

                    Toast.makeText(this, "Content:" + contents + "Format:" + format,

                            Toast.LENGTH_LONG).show();

                     

                } else if (resultCode == RESULT_CANCELED) {

                    // Handle cancel

                    Toast toast = Toast.makeText(this, "Scan was Cancelled!", Toast.LENGTH_LONG);

                    toast.setGravity(Gravity.TOP, 25, 400);

                    toast.show();

                   

                }

            }

        }

    }


Code:
import android.app.Activity;

import android.app.AlertDialog;

import android.content.ActivityNotFoundException;

import android.content.DialogInterface;

import android.content.Intent;

import android.net.Uri;

import android.os.Bundle;

import android.provider.MediaStore;

import android.view.Gravity;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.widget.Toast;



public class ViewOption extends Activity {



    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_view_option);

    }



    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.view_option, menu);

        return true;

    }



    @Override

    public boolean onOptionsItemSelected(MenuItem item) {

        // Handle action bar item clicks here. The action bar will

        // automatically handle clicks on the Home/Up button, so long

        // as you specify a parent activity in AndroidManifest.xml.

        int id = item.getItemId();

        if (id == R.id.action_settings) {

            return true;

        }

        return super.onOptionsItemSelected(item);

    }

}

Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context="{relativePackage}.${activityClass}" >



    <TextView

        android:id="@+id/textView1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentRight="true"

        android:background="#008080"

        android:padding="5dp"

        android:text="Android Read and Write Text form File"

        android:textColor="#fff" />



    <EditText

        android:id="@+id/editText1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentRight="true"

        android:layout_below="@+id/textView1"

        android:layout_marginTop="22dp"

        android:ems="10" 

        android:layout_margin="5dp">

        <requestFocus />

    </EditText>



    <Button

        android:id="@+id/button1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentRight="true"

        android:layout_below="@+id/editText1"

        android:text="Write Text into File"

        android:onClick="WriteBtn" 

        android:layout_margin="5dp"/>

   

    <Button

        android:id="@+id/button2"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentRight="true"

        android:layout_below="@+id/button1"

        android:text="Read Text From file"

        android:onClick="ReadBtn"

        android:layout_margin="5dp" />

   

</RelativeLayout>

Code:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/container"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:background="#ffffff"

    android:backgroundTint="@android:color/holo_blue_bright"

    android:foregroundTint="@android:color/holo_red_light"

    android:orientation="vertical"

    tools:context="com.example.Caregiver.First" >



    <TextView

        android:id="@+id/textView1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_gravity="center|top"

        android:layout_margin="20dp"

        android:text="Scan Options"

        android:textColor="#000000"

        android:textSize="30dp" />



    <Button

        android:id="@+id/BarCode"

        android:layout_width="match_parent"

        android:layout_height="64dp"

        android:layout_margin="10dp"

        android:backgroundTint="@android:color/holo_orange_dark"

        android:gravity="center"

        android:onClick="BarCode"

        android:text="BarCode"

        android:textSize="18dp" />

   

    <Button

        android:id="@+id/scanner5"

        android:layout_width="match_parent"

        android:layout_height="75dp"

        android:layout_gravity="center"

        android:layout_margin="10dp"

        android:backgroundTint="@android:color/holo_red_dark"

        android:gravity="center"

        android:onClick="Camera"

        android:text="Image"

        android:textSize="18dp" >



</Button>



    <Button

        android:id="@+id/QRCode"

        android:layout_width="match_parent"

        android:layout_height="64dp"

        android:layout_margin="10dp"

        android:layout_marginTop="14dp"

        android:backgroundTint="@android:color/holo_orange_dark"

        android:gravity="center"

        android:onClick="QRCode"

        android:text="QRCode"

        android:textSize="18dp" />



</LinearLayout>

Code:
<?xml version="1.0" encoding="utf-8"?>

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/container"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:background="#ffffff"

    android:backgroundTint="@android:color/holo_blue_bright"

    android:foregroundTint="@android:color/holo_red_light"

    android:orientation="vertical"

    tools:context="com.javacodegeeks.androidstartactivityforresultexample.ActivityOne" >

     

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center|top"

android:layout_margin="20dp"

android:text="Welcome to my Caregiver App"

android:textColor="#000000"

android:textSize="30dp" />





<Button

android:id="@+id/scanner"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_purple"

android:gravity="center"

android:onClick="Create"

android:text="Create"

android:textSize="18dp" />



<Button

android:id="@+id/scanner2"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_orange_dark"

android:gravity="center"

android:onClick="scan"

android:text="Scan"

android:textSize="18dp" />



<Button

android:id="@+id/scanner3"

android:layout_width="250dp"

android:layout_height="80dp"

android:layout_gravity="center"

android:layout_margin="10dp"

android:backgroundTint="@android:color/holo_blue_dark"

android:gravity="center"

android:onClick="viewscan"

android:text="View"

android:textSize="18dp" />





</LinearLayout>

Code:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/container"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:background="#ffffff"

    android:backgroundTint="@android:color/holo_blue_bright"

    android:foregroundTint="@android:color/holo_red_light"

    android:orientation="vertical"

    tools:context="com.example.Caregiver.ScanOptions" >



    <TextView

        android:id="@+id/textView1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_gravity="center|top"

        android:layout_margin="20dp"

        android:text="Scan Options"

        android:textColor="#000000"

        android:textSize="30dp" />



    <Button

        android:id="@+id/BarCode"

        android:layout_width="match_parent"

        android:layout_height="64dp"

        android:layout_margin="10dp"

        android:backgroundTint="@android:color/holo_orange_dark"

        android:gravity="center"

        android:onClick="BarCode"

        android:text="BarCode"

        android:textSize="18dp" />

   

    <Button

        android:id="@+id/scanner5"

        android:layout_width="match_parent"

        android:layout_height="75dp"

        android:layout_gravity="center"

        android:layout_margin="10dp"

        android:backgroundTint="@android:color/holo_red_dark"

        android:gravity="center"

        android:onClick="Camera"

        android:text="Image"

        android:textSize="18dp" >



</Button>



    <Button

        android:id="@+id/QRCode"

        android:layout_width="match_parent"

        android:layout_height="64dp"

        android:layout_margin="10dp"

        android:layout_marginTop="14dp"

        android:backgroundTint="@android:color/holo_orange_dark"

        android:gravity="center"

        android:onClick="QRCode"

        android:text="QRCode"

        android:textSize="18dp" />



</LinearLayout>

Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:background="#ffffff"

    android:backgroundTint="@android:color/holo_green_dark"

    android:paddingBottom="@dimen/activity_vertical_margin"

    android:paddingLeft="@dimen/activity_horizontal_margin"

    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin"

    tools:context="com.example.Caregiver.ViewOption" >



<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center|top"

android:layout_margin="20dp"

android:text="View Options"

android:textColor="#000000"

android:textSize="30dp" />





<Button

    android:id="@+id/Buttonview"

    android:layout_width="match_parent"

    android:layout_height="75dp"

    android:layout_below="@+id/textView1"

    android:layout_centerHorizontal="true"

    android:layout_margin="10dp"

    android:backgroundTint="@android:color/holo_red_dark"

    android:gravity="center"

    android:onClick="Viewfile"

    android:text="View Page"

    android:textSize="18dp" />



</RelativeLayout>
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones