chrome ignores included header in intent - android

i used to add header to intent as below:
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(baseUrl));
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle bundle = new Bundle();
TokenManager manager = TokenManager.getTokenManager();
bundle.putString("Authorization", manager.getAuthorization());
bundle.putString("Content-Type","application/x-www-form-urlencoded");
myIntent.putExtra(Browser.EXTRA_HEADERS, bundle);
mContext.startActivity(myIntent);
but it seems it does not work on newest version of google chrome. it ignores headers as there is no header hence i encounter with authorization problem.
can anybody help me? ( i need to use intent not webview )

Try this solution
I have a Map object that I stored header information. Then the following:
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
Bundle bundle = new Bundle();
if(mExtraHeader!=null){
for(String key: mExtraHeader.keySet()){
bundle.putString(key, mExtraHeader.get(key));
}
}
i.putExtra(Browser.EXTRA_HEADERS, bundle);
startActivity(i);

Related

How can I convert intent to deep link?

I have sample code as below for Android Java:-
public void OpenAppbyName(String appname, String user, String password) {
ComponentName componetName = new ComponentName("com.xxx","com.xxx.yyy.zzz");
Intent intent = new Intent();
intent.setComponent(componetName);
Bundle bundle = new Bundle();
bundle.putString("data", "user1" + "|" + "abc123"); intent.putExtras(bundle);
startActivity(intent);
}
May I know how can I trigger and access this link in react native?
Example something like this :=
com.xxx://com.xxx.yyy.zzz?data=user1|abc123
Please help..

Android programming passing values

Sorry if we're doing anything wrong, we just started a crash course in android and we are trying to pass a value using the bundle but it does not show any error, it only crashes after the attempt. Here is the code block below.
ps, pls feel free to edit the post if you see anything wrong with it.
Bundle b = new Bundle(); //to pass values in meals.java
b.putStringArray("breakfast1" , new String[]{breakfast1[0]});
Intent gene = new Intent(Calories.this, Days.class);
//to pass the activity in another activity
gene.putExtras(gene);
startActivity(gene);
//second.java bundle receiving code block
break1 = (TextView) findViewById(R.id.break1);
Intent gene = getIntent();
String[] break2 = gene.getStringArrayExtra("breakfast1");
break1.setText(break2[0]);
Change gene.putExtras(gene); to gene.putExtras(b); and retrieve bundle using b = getIntent().getExtras()
FirstActivity
Bundle b = new Bundle(); //to pass values in meals.java
b.putStringArray("breakfast1" , new String[]{breakfast1[0]});
Intent gene = new Intent(Calories.this, Days.class);
//to pass the activity in another activity
gene.putExtras(b); //put bundle to intent
startActivity(gene);
In Second Activity Second.java
break1 = (TextView) findViewById(R.id.break1);
Intent gene = getIntent();
Bundle b = gene.getExtras(); //get bundle from intent
String[] break2 = b.getStringArrayExtra("breakfast1"); //get array list from bundle
break1.setText(break2[0]);
replace with this.
Bundle b = new Bundle(); //to pass values in meals.java
b.putStringArray("breakfast1" , new String[]{breakfast1[0]});
Intent gene = new Intent(Calories.this, Days.class);
//to pass the activity in another activity
gene.putExtras(b); // put b not gene
startActivity(gene);
//second.java bundle receiving code block
break1 = (TextView) findViewById(R.id.break1);
Intent gene = getIntent();
String[] break2 = gene.getStringArrayExtra("breakfast1");
break1.setText(break2[0]);
Please try this
Bundle b = new Bundle();
b.putStringArray(key, new String[]{value1, value2});
Intent i = new Intent(context, Class);
i.putExtras(b);
And for receiving side
Bundle b = this.getIntent().getExtras();
String[] array = b.getStringArray(key);

Android Intent for deep-linking to Deezer Search

I am trying to perform a search on Deezer by sending the following intent:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.deezer.com/search/" + query));
this.startActivity(intent);
In a previous version the web browser opened with a link saying "Open in Deezer" (or the like).
But in the current version this doesn't work anymore.
Is there any way to open the Deezer app and perform a search?
I have already tried the following (without success):
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("deezer://search/" + query));
this.startActivity(intent);
There are many deeplinks you can use to search for content inside the Deezer app. You do have the basic search like this :
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("deezer://www.deezer.com/search/" + query));
this.startActivity(intent);
But you can also be more precise :
// Search for an artist, will display the best match
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("deezer-query://www.deezer.com/artist?query" + query));
this.startActivity(intent);
// Search for an album, will display the best match
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("deezer-query://www.deezer.com/album?query" + query));
this.startActivity(intent);
// Search for a track, will display the best match
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("deezer-query://www.deezer.com/track?query" + query));
this.startActivity(intent);
I believe it should be
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("deezer://www.deezer.com/search/" + query));
this.startActivity(intent);
The scheme of the Uri needs to be deezer. You have set it as http.
Try this. This should work.

Using intent.Action_call for user inputted number

Help me modify with necessary changes needed to use the value/string(number) passed by user for phone-calling that string itself
Intent phnIntent = new Intent(Intent.ACTION_CALL);
phnIntent.setData(Uri.parse("tel:+91987654321"));
you can use like this :
String strTelNo = "+91987654321";
Intent intent = new Intent("android.intent.action.CALL");
Uri data = Uri.parse("tel:"+ strTelNo );
intent.setData(data);
startActivity(intent);
Try this link.
Make sure you add the necessary permission in the Android Manifest.
<uses-permission android:name="android.permission.CALL_PHONE" />
Just add the line startActivity(phnIntent);
EDIT:
Activity A
Intent someIntent = new Intent(A.this, B.class);
someIntent.putExtra("phoneNumber", number);
startAcitivty(someIntent);
Acitivity B
Bundle extras = getIntent().getExtras();
String number = extras.getInt("phoneNumber");
Use the number string to make the call.

How to recive Image file with Intents?

am sending an image with help of intent as follow
Uri profileImage = Uri.parse("android.resource://Tset/res/drawable-hdpi/arr.jpeg");
details.setType("image/png");
details.putExtra(Intent.EXTRA_STREAM, profileImage);
startActivity(details);
how do i can get the image path in my receiving end activity ?
Try This
Pass image url from current activity using intent
Intent myIntent = new Intent(this, MyImageViewActivity.class);
Bundle bundle = new Bundle();
bundle.putString("image", path);
myIntent.putExtras(bundle);
startActivityForResult(myIntent, 0);
Here path is
String path="android.resource://Tset/res/drawable-hdpi/arr.jpeg"
in your receiving activity
Bundle bundle = this.getIntent().getExtras();
String path = bundle.getString("image");
Finally i done it with help of id of the image as follow ! !
thanks for all of ur reply ! !
profilePictureID=R.drawable.image name;//name of image in drawable folder dont use extensions like.jpg and all
IntentObject.putExtra("ImageID",profilePictureID);
startActivity(IntenetObject);
In receiving activity
int pictureId=getIntent().getIntExtra("ImageID",0);
profilePicture.setImageResource(pictureId);
Try this..
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path)), "image/png");
startActivity(intent);

Categories

Resources