[android-developers] How to get writable DocumentFile Uri from a Media real path?

2015-05-23 Thread Ichsan
I have a situation in Lollipop where I have:

 1. Directory tree (`DocumentFile`) which is granted from user. 
 2. A collection of audio files that need to modify retrieved from media 
provider.

Uri mediaUri = Uri.withAppendedPath(MediaStore.Audio.Media.
EXTERNAL_CONTENT_URI, 
45);



Then, how to write a stream into one of those files?

DocumentFile 
https://developer.android.com/reference/android/support/v4/provider/DocumentFile.html
 
is a new mechanism which allows us to modify files in Lollipop. It is not 
the same case with this post 
http://stackoverflow.com/questions/7738192/how-to-get-contact-photo-uri 

Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Android transition doesn't care about targetId in transitionSet?

2015-02-02 Thread Ichsan
I'm confused about how transitionSet is used. This is my definition:

?xml version=1.0 encoding=utf-8?
transitionSet xmlns:android=http://schemas.android.com/apk/res/android; 
android:transitionOrdering=sequential
slide android:slideEdge=bottom android:startDelay=0
targets
target android:targetId=@id/action_save /
/targets
/slide
slide android:slideEdge=top
targets
target android:targetId=@id/image_album_background /
/targets
/slide
slide
android:duration=500
android:slideEdge=bottom
targets
target android:targetId=@id/fields_container /
/targets
/slide
/transitionSet



This way, all views will slide from bottom edge. But if I change the order 
into this:

?xml version=1.0 encoding=utf-8?
transitionSet xmlns:android=http://schemas.android.com/apk/res/android; 
android:transitionOrdering=sequential
slide android:slideEdge=top
targets
target android:targetId=@id/image_album_background /
/targets
/slide
slide android:slideEdge=bottom android:startDelay=0
targets
target android:targetId=@id/action_save /
/targets
/slide
slide
android:duration=500
android:slideEdge=bottom
targets
target android:targetId=@id/fields_container /
/targets
/slide
/transitionSet



Then, all will slide from top edge. It seems that Android only cares about 
the first transition.

This is the layout:

?xml version=1.0 encoding=utf-8?
FrameLayout xmlns:android=http://schemas.android.com/apk/res/android;
xmlns:fab=http://schemas.android.com/apk/res-auto;
xmlns:tools=http://schemas.android.com/tools;
android:layout_width=match_parent
android:layout_height=match_parent

ScrollView
android:layout_width=match_parent
android:layout_height=match_parent

RelativeLayout
android:layout_width=match_parent
android:layout_height=wrap_content
android:orientation=vertical

!-- Picture --
RelativeLayout
android:id=@+id/image_album_background
android:layout_width=match_parent
android:layout_height=wrap_content
android:background=#ff00

ImageView
android:id=@+id/image_album
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_centerHorizontal=true
android:adjustViewBounds=true
android:contentDescription=No art
android:maxHeight=320dp
android:maxWidth=320dp
android:src=@drawable/ic_noart
android:transitionName=transition_album_cover
tools:ignore=HardcodedText /

Button
android:id=@+id/btn_img_marker
android:layout_width=20dp
android:layout_height=20dp
android:layout_alignEnd=@+id/image_album
android:layout_alignParentBottom=true
android:layout_alignRight=@+id/image_album
android:background=#ff56bb21 /
/RelativeLayout

LinearLayout
android:id=@+id/fields_container
android:layout_width=match_parent
android:layout_height=wrap_content
android:layout_below=@+id/image_album_background
android:background=#
android:orientation=vertical
android:padding=@dimen/frame_margin

CheckBox
android:id=@+id/cb_embed_art
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_gravity=center_horizontal
android:text=@string/label_embed_art /

TextView
android:id=@+id/text_filepath
android:layout_width=match_parent
android:layout_height=wrap_content
android:gravity=center_horizontal
android:text=/mnt/data/path/to/file/audio.mp3 /
/LinearLayout

RelativeLayout
android:layout_width=match_parent
android:layout_height=wrap_content
android:layout_below=@id/fields_container
android:background=#
android:padding=24dp
!-- Title --
LinearLayout
android:id=@+id/title_row
android:layout_width=fill_parent
android:layout_height=wrap_content
android:orientation=horizontal

TextView
style=@style/label
android:layout_width=100dp
android:layout_height=wrap_content
android:text=@string/label_title /

EditText
android:id=@+id/edit_title
android:layout_width=0dp
android:layout_height=wrap_content
android:layout_weight=1
android:inputType=text /
/LinearLayout

!-- Artist --
LinearLayout
android:id=@+id/artist_row
style=@style/input_row
android:layout_width=match_parent
android:layout_height=wrap_content
android:layout_below=@id/title_row
android:orientation=horizontal

TextView
style=@style/label
android:layout_width=100dp
android:layout_height=wrap_content
android:text=@string/label_artist /

AutoCompleteTextView
android:id=@+id/edit_artist
style=?android:editTextStyle
android:layout_width=match_parent
android:layout_height=wrap_content
android:inputType=text /
/LinearLayout

!-- Album artist --
LinearLayout
android:id=@+id/album_artist_row
style=@style/input_row
android:layout_width=match_parent
android:layout_height=wrap_content
android:layout_below=@id/artist_row
android:orientation=horizontal

TextView
style=@style/label
android:layout_width=100dp
android:layout_height=wrap_content
android:text=@string/label_album_artist /

AutoCompleteTextView
android:id=@+id/edit_album_artist
style=?android:editTextStyle
android:layout_width=match_parent
android:layout_height=wrap_content
android:inputType=text /
/LinearLayout

!-- Album --
LinearLayout
android:id=@+id/album_row
style=@style/input_row

[android-developers] Mocking ContentResolver

2014-05-25 Thread Muhammad Ichsan
Dear All

I want to test my activity which uses media ContentResolver.

Is there any way to test it without using real ContentResolver but, only mock?

From 
http://dtmilano.blogspot.com/2009_12_01_archive.html#MockContextWithMockContentProv,
it is said that I have to use MockContextWithMockContentResolver. But
I see no such class.

Thanks

-- 
~The best men are men who benefit to others
http://www.michsan.web.id 一緒に勉強しましょう!

Yang berkualitas memang beda rasanya!
http://rizqi-cookies.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Compass Library

2012-11-18 Thread Ichsan
Dear All

I'm developing a compass application. I see that orientation sensor is 
deprecated, so I use magnetic sensor in combination with acceleration 
sensor (for devices which have ones).

I'm only interested in azimuth value. Some devices give me smooth value, 
but some give me very unstable value (jumping values).

Is there any compass library out there which simply gives me azimuth value 
without headache?

Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Warning users of strong magnetic field

2012-10-13 Thread Ichsan
Does anybody know how to warn users of string magnetic field? I'm creating 
a compass application. But when there are magnetic items around, the north 
direction is going wrong.

Using SensorEventListener#onAccuracyChanged doesn't help.

Is there any tutorial telling me how to handle this problem?

FYI, I followed this tutorial to create this compass 
app: 
http://stackoverflow.com/questions/4819626/android-phone-orientation-overview-including-compass

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Best strategy in handling location change

2012-09-26 Thread Ichsan


On Monday, 24 September 2012 12:17:51 UTC+7, TreKing wrote:

 On Sun, Sep 23, 2012 at 11:25 PM, Muhammad Ichsan 
 ich...@gmail.comjavascript:
  wrote:

 To simplify, this is an application which set off alarm by location. The 
 alarm is determined by user coarse location.

 Providing less information does not simplify anything.


The app is an app which reminds users of doing a task. When should the 
alarm go off? The alarm is scheduled by sun positioning which is relative 
to user's coarse position. So, when a user travels far away, the alarm can 
change. The 100 miles movoment probably may shift time about 1 minute 
(based on sun position. The method is approached by calculation based on 
user coarse location). I'm sorry if it was not clear, but is that clear 
enough now?




-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Best strategy in handling location change

2012-09-23 Thread Ichsan
Currently, I'm creating an app which alarms user tasks at specific time. 
The time is automatically calculated based on coarse location. So, when 
users fly miles away, the alarm time has become invalid. So the app needs 
to recalculate the time. FYI, the alarm should be always on (when exiting 
the app, the alarm is still set).

To solve this, I don't want to listen for coarse location change since it 
eats my battery. Instead, my strategy is by starting alarm each 2 hours 
just to start a location listener (to fix the task alarm). What do you 
think of this strategy?

How to prepare an alarm only once? Can I check if I've done it?

Those are my questions.

Thanks...

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Best strategy in handling location change

2012-09-23 Thread Muhammad Ichsan
To simplify, this is an application which set off alarm by location. The
alarm is determined by user coarse location.
On Sep 24, 2012 10:22 AM, TreKing treking...@gmail.com wrote:

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Android LVL

2012-09-15 Thread Ichsan
If you read the documentation, it is clear that you need to upload the app 
without publishing it.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Best practice in handling huge overlay items on Android Maps

2012-08-30 Thread Ichsan
Dear All,

I have a situation where I need to tell users where the nearby ATMs are 
located. The problem is if the bank has 1 ATMs.

When I use Maps for web programmings, I usually only load ATMs on visible 
area. When user do panning or zooming out, I request back-end server to 
provide more ATMs and redraw all overlay items. But I don't think we can 
use this technique on mobile device.

If I use technique from 
https://developers.google.com/maps/documentation/android/hello-mapview, I 
get a performance hit. 

What is the best way to handle this? We know that there are some concerns:
1. Loading all ATMs will eat memory a lot.
2. Loading ATMs on visible area may eat a lot of data connection as users 
do panning. (I don't know either how to get the visible coordinate border)

I've done some experiments. Loading 1000 overlay items (ATMs) (1000 x 
itemizedOverlay.addOverlayItem(anAtm);  and 1 x populate()) has consumed 5 
seconds.

Is there any best practice in doing this? I really hope Google would give 
developers the best practice.

I've also posted this question here 
http://stackoverflow.com/questions/12196158/best-practice-in-handling-huge-overlay-items-on-android-maps

Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Confused with C2DM

2012-05-31 Thread Ichsan
Dear All, 

I'm currently learning how to use C2DM. But I still got confused about 
concept of sender and client login.

*# The sender*
Do I have to create an email account e.g. ichsan.my...@gmail.com? It seems 
that one email is for one app only (e.g. package = ichsan.myapp). Is it 
true?

*# Client login*
How to create client login? Google says that I should use OAuth 2. But I 
still failed to use it. This is my steps. Would you please check if they're 
correct?

I log out from my personal email and log in as ichsan.my...@gmail.com.

1. Create a client ID
Since my application server is going to push message into Google C2DM 
server, I create a client id for my application server. I go to 
https://code.google.com/apis/console to create a client. This client type 
is Installed Application. I get a client ID = CLNT123

2. Open C2DM service.
Sadly I cannot find it. I skip this part. Is it Okay?

3. Testing
# Getting a token
curl -k -d 
response_type=codeclient_id=CLNT123scope=https://www.googleapis.com/c2dmredirect_uri=urn:ietf:wg:oauth:2.0:oob;
 
https://accounts.google.com/o/oauth2/auth

But I got redirect (so I run it in browser instead). Should my application 
server follow that redirect to get the token? How long I a valid token last?
I got token TOKEN123

# Push a message
As my app started and registered itself using ichsan.my...@gmail.com as 
sender, I got error: Can not find the API. I'm sure I've download all 
libraries available for Android 2.2 and 4.0. Did I miss something?

If this succeed, is the following snippet the correct way to test pushing a 
message?

curl -k -H Authorization: Bearer TOKEN123 --trace curl_trace.txt -d 
registration_id=GENERATED_MYAPP_REG_ID -d data.message=something to 
talk -d collapse_key=0 https://android.apis.google.com/c2dm/send

Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en