Skip to content

Commit

Permalink
use MediaScannerConnection istead of sendBroadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
phunehehe committed Feb 23, 2014
1 parent d87ce32 commit 9b93001
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
9 changes: 9 additions & 0 deletions .idea/libraries/protocol_1_0_4.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/libraries/sentry_0_1_4.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 2 additions & 22 deletions fooCam/fooCam-fooCam.iml
Expand Up @@ -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>

5 changes: 2 additions & 3 deletions fooCam/src/main/java/net/phunehehe/foocam/MainActivity.java
@@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down

3 comments on commit 9b93001

@programmin1
Copy link

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

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.