Skip to content
Permalink
Browse files
use MediaScannerConnection istead of sendBroadcast
  • Loading branch information
phunehehe committed Feb 23, 2014
1 parent d87ce32 commit 9b93001648eb8e486653cd47e95577c3393c6ebc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

@@ -70,28 +70,8 @@
<orderEntry type="jdk" jdkName="Android API 18 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-18.0.0" level="project" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/protocol-1.0.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/lib/protocol-1.0.4.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/sentry-0.1.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/lib/sentry-0.1.4.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="library" exported="" name="sentry-0.1.4" level="project" />
<orderEntry type="library" exported="" name="protocol-1.0.4" level="project" />
</component>
</module>

@@ -1,10 +1,9 @@
package net.phunehehe.foocam;

import android.app.Activity;
import android.content.Intent;
import android.hardware.Camera;
import android.hardware.Camera.PictureCallback;
import android.net.Uri;
import android.media.MediaScannerConnection;
import android.os.Bundle;
import android.os.Environment;
import android.view.Display;
@@ -145,7 +144,7 @@ public void onPictureTaken(byte[] data, Camera camera) {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.fromFile(pictureFile)));
MediaScannerConnection.scanFile(this, new String[]{pictureFile.toString()}, null, null);
} catch (IOException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
}

3 comments on commit 9b93001

@programmin1
Copy link

@programmin1 programmin1 commented on 9b93001 Mar 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greetings Hoang Xuan Phu, I was wondering if this is your app on Google Play? https://play.google.com/store/apps/details?id=net.phunehehe.foocam

The id is the same as your app.

@phunehehe
Copy link
Owner Author

@phunehehe phunehehe commented on 9b93001 Mar 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@programmin1 OMG I didn't notice somebody submitted it on Google Play as a non-free app. It's not mine.

@phunehehe
Copy link
Owner Author

@phunehehe phunehehe commented on 9b93001 Mar 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up! I have updated the README to clarify this.
See also https://phunehehe.net/foocam-useful-enough-copied/.

Please sign in to comment.