Cannot found image when pickup from my app - android

i have write an app like camera on android. But when pick an imagefrom my app, it have error can not found image.
imvpick.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent pickIntent = new Intent("inline-data");
if (pickIntent != null) {
pickIntent.putExtra("data", BitmapFactory.decodeResource(getResources(), R.drawable.picker));
setResult(RESULT_OK, pickIntent);
finish();
}
}
});
and in manifest
<activity android:name=".CameraActivity" android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.media.action.IMAGE_CAPTURE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Related

How to open a url in chrome from app having deep linking

The main theme of my app is to open a website from my app into the chrome engine when user clicks on the button in the app. When i have implemented the code for click event it working fine, but when i have implemented the deep linking for my app, these was an that issue i'm facing.
My App is showing some thing like this when i click on the button. Instead of this when user clicks on the button the website has to launch in chrome engine.
The MainActivity file of my app look like:-
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
intent = getIntent();
action = intent.getAction();
uri = intent.getData();
if (uri != null) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://stackoverflow.com/")));
}
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://stackoverflow.com/")));
}
});
}
The Mainefest file of my app look like:-
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="stackoverflow.com"
android:scheme="http" />
</intent-filter>
</activity>
</application>
I have modified the code in the button click event, by setting package name of the chrome to the intent, and working fine as per my requirement.
Intent intent1 = new Intent(Intent.ACTION_VIEW);
intent1.setData(Uri.parse("http://stackoverflow.com/"));
intent1.setPackage("com.android.chrome");
startActivity(intent1);

About the XML|intent-filter

#Override
public void onClick(View v) {
Intent intent = new Intent("com.example.ui05.ACTION_START");
intent.addCategory("com.example.ui05.MY_CATEGORY");
startActivity(intent);
}
the relevant Manifest is:
<activity android:name=".SecondActivity" >
<intent-filter>
<action android:name="com.example.ui05.ACTION_START" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.CATEGORY" />
</intent-filter>
</activity>
#Override
public void onClick(View v) {
Intent intent = new Intent("com.example.ui05.ACTION_START");
startActivity(intent);
}
the relevent manifest is:
<activity android:name=".SecondActivity" >
<intent-filter>
<action android:name="com.example.ui05.ACTION_START" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
why the first situation would give an Exception :
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=com.example.ui05.ACTION_START cat=[com.example.ui05.MY_CATEGORY] }
The second situation is OK.
Your intent filter doesn't include the category for the category you're specifying in the intent. Change your intent filter category specifying android.intent.category.CATEGORY to com.example.ui05.MY_CATEGORY and it should work.

Android: ActivityNotFound Exception

Basically the error is in Manifest file I think.
Here is the code for MainActivity.java
private void setInitialScreen( int visibility ) {
Button choose_picture = (Button) findViewById(R.id.choose_picture);
choose_picture.setVisibility(visibility);
choose_picture.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.addCategory("choose_file");
Log.d("mainactivity", intent.getCategories().toString());
startActivityForResult(intent, 0);
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(data.hasCategory("choose_file") && resultCode == RESULT_OK) {
Uri uri = data.getData();
setPhotoEditScreen(0, uri);
}
}
private void setPhotoEditScreen( int visibility, Uri uri ) {
View screen_image_editing = findViewById(R.id.screen_image_editing);
screen_image_editing.setVisibility(visibility);
ImageView main_image = (ImageView) findViewById(R.id.main_image);
main_image.setImageURI(uri);
}
and this is the manifest entry
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="choose_file"/>
</intent-filter>
</activity>
Screenshot of Logcat
https://www.dropbox.com/s/w0hi3g7n3i966t6/Screenshot%202014-04-14%2010.33.17.jpg
<intent-filter >
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="choose_file"/>
</intent-filter>
Please do remove the following lines from manifest.xml and try it out , I think since it has two intent filters there might be a problem and in the android name and have you included the package name in the
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.splash_1"
Like this

create a thread into setOnClickListener

I have an Intent into setOnClickListener that it open a list of contacts into a new activity,now,
when I test this example at AVD it is ok, but when I test
on a mobile phone as soon as I touch button I get closing message.
why ?!
Is need a Thread ?
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_PICK,Uri.parse("content://contacts/"));
startActivityForResult(intent, 1);
}});
My Manifest.xml
<activity
android:name="com.example.ex21.ShoMyList"
android:label="Picker">
<intent-filter>
<action android:name="Piker"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<data android:path="contacts" android:scheme="content"></data>
</intent-filter>
</activity>
<activity
android:name="com.example.ex21.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
use :
Intent intent = new Intent(Intent.ACTION_PICK, Uri.parse("content://picker/contacts/"));
or
Intent intent= new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
I think your uri is incorrect.

Getting android.content.ActivityNotFoundException with Zxing

I have followed the following tutorial : http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/
But even after editing android manifest xml as told there I am getting the following error:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.google.zxing.client.android.SCAN pkg=com.google.zxing.client.android (has extras) }
My Code :
public class BarCodeScannerActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button ok;
ok=(Button) findViewById(R.id.b1);
ok.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("Helllllllloooooooo");
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE","QR_CODE_MODE");
startActivityForResult(intent, 0);
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
System.out.println("onActivityResult________resultCode________ "+resultCode);
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
System.out.println("contentsssssssssssssssssssssss" + contents);
Toast.makeText(getApplicationContext(),"Congratulations!!!... Product Code"+ contents + "On Scanning This Item..." ,Toast.LENGTH_LONG).show();
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
System.out.println("Formaattttttttttttttt " + format);
// Handle successful scan
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}
}
And mainfest file:
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".BarCodeScannerActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.CAMERA" />
Hi
Now i am getting a strange problem of attached screen shot once i updated my manifest as follows:
<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
![enter image description here][1]
<activity android:name=".ScanItemActivity"
android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
</activity>
I mean it says ""Sorry, the Android camera encountered a problem. You may need to
restart the device."
Nothing is there in logcat.
This is quite confused. You don't need to change your manifest at all if you are integrating by Intent, so remove anything you changed just for the integration.
The app is not installed, and you are not handling this properly. You must catch ActivityNotFoundException, or determine ahead of time that the app to handle the Intent is installed.
But, there is no need for any of this complexity. See http://code.google.com/p/zxing/wiki/ScanningViaIntent . You can use IntentIntegrator, which does all of this for you correctly, in a few lines of code.

Categories

Resources