QR Code Decoder, address issue of variables - java

How would I be able to call a string from one activity to another?
My code isn't working, I am trying to achieve a program that can browse
the images on the SD card of my phone and return the address of the image.
I am developing a QR Code decoder based on the zxing library.
private void onFileClick(Option o)
{
//Toast.makeText(this, "File Clicked: "+o.getName(), Toast.LENGTH_SHORT).show();
Toast.makeText(this, "File Clicked: "+o.getPath(), Toast.LENGTH_SHORT).show();
QRDecoder qr = null;
str = o.getPath();
qr.setFile(str);
Intent intent = new Intent(this, QRDecoder.class);
Log.d("filter", str);
Log.d("filter", qr.my_url);
startActivity(intent);
}

before calling startActivity
intent.putExtra("path", str);
in onCreate of the QRDecoder
String path = getIntent().getStringExtra("path");

Related

"market://details?id=" + appPackageName opens the app not the playstore page

i asked a question on how should i open the playstore page using an app link on my app. i got an answer to use "market://details?id=" + appPackageName to open the play store app but instead of opening the playstore page its re opening my app. whats the fix?
enter code here
protected void Updateclick(View view) {
String appPackageName="io.kodular.samithuaz.smartQ";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
}
Try this.You need to specify proper store URI for the different stores.
take reference link
protected void Updateclick(View view) {
final String appPackageName = getPackageName();
try {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
}
what i was using was an image click that why it didnt worked. when i used a button click it worked.

open map location on image click but some device having Google Map cant open the intent

currently i am using this but(to open map location on image click but some device having GoogleMap cant open the intent) the issue is even device has apps to handle the map intent it wont execute that part
any better way to do this?
like option to select from available apps and no apps to handle that then go for browser
private void openMap()
{
String Packagename ="com.google.android.apps.maps";
if (appInstalledOrNot(Packagename))
{
Uri uri = Uri.parse("geo:0,0?q=V.V.P.+Engineering+College+Kalavad+Road+Virda+Vajadi,+Rajkot");
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
intent.setPackage("com.google.android.apps.maps");
startActivity(intent);
}else
{
try {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://goo.gl/maps/ETVvFWw453CoeBHs9"));
startActivity(myIntent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
Toast.makeText(getContext(), "Map application not found", Toast.LENGTH_SHORT).show();
}
}

How to send Activation code like *777# to dialer using an Intent?

I want to send code *777# to dialer in android using intent but i have a problem only *777 key code will be displayed on dialer not # how to resolve this issue i'm new in android developer so please help me out this problem.
String dialler_Code = "*777#";
Toast.makeText(this, "clicked", Toast.LENGTH_LONG)
.show();
// Use format with "tel:" and phoneNumber created is stored in u.
Uri u = Uri.parse("tel:" + dialler_Code);
// Create the intent and set the data for the intent as the phone number.
Intent i = new Intent(Intent.ACTION_DIAL, u);
try {
// Launch the Phone app's dialer with a phone number to dial a call.
startActivity(i);
} catch (SecurityException s) {
// show() method display the toast with exception message.
Toast.makeText(this, s.getMessage() , Toast.LENGTH_LONG)
.show();
}
Try with String dialler_Code = Uri.encode("*777#");
**Use this : **
String enCodedHash = Uri.encode("#");
String number = "*151*1" + enCodedHash;
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+ number));
startActivity(callIntent);

How to send Whatsapp message to new number

I' d like to send a whatsapp message by clicking on a button to a number that comes from the Android Activity (that in turn fetches from a server).
The number to which I have to send a new is NOT an existing contact on my phone.
I know how to open Whatsapp app from my app.
The following piece of code deals with opening whatsapp from an Adapter:
Intent sendIntent = new Intent();
sendIntent.setPackage("com.whatsapp");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
this code opens Whatsapp but I don't know how to pass it the number to which I have to send the message
Try this
public void onClickWhatsApp(View view) {
PackageManager pm=getPackageManager();
try {
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
String text = "YOUR TEXT HERE";
PackageInfo info=pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
//Check if package exists or not. If not then code
//in catch block will be called
waIntent.setPackage("com.whatsapp");
waIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(waIntent, "Share with"));
} catch (NameNotFoundException e) {
Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT)
.show();
}
}

PDF intent in android

while developing an android app , I am getting error "sorry we were unable to find the document at the original source" while using the following code : please advise
#Override
public boolean shouldOverrideUrlLoading( WebView view, String url ) {
if (url.contains(".pdf")){
Toast.makeText(view.getContext(), "chand", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "application/pdf");
view.getContext().startActivity(intent);
//String googleDocs = "http://docs.google.com/gview?embedded=true&url=";
//view.loadUrl(googleDocs + url);
//Toast.makeText(view.getContext(), "chand", Toast.LENGTH_LONG).show();
//String pdfurl = "http://docs.google.com/gview?embedded=true&url=" + url;
//Log.i(TAG, "Opening PDF: " + url);
//view.getSettings().setJavaScriptEnabled(true);
//view.loadUrl(pdfurl);
}
return false;
}
To use that intent you need to download the PDF to the device onto the sdcard then give the uri to the pdf on the sd card in the intent.

Categories

Resources