Peter Tran's profile on Hashnode. Software Developer at GoPro
Trying out Hashnode’s Devblog, check me out over there: https://hashnode.com/@petertran
Acquired Stardust
tumblr dot com
we're not kids anymore.

titsay
hello vonnie
Game of Thrones Daily

Kaledo Art

pixel skylines

roma★
will byers stan first human second
styofa doing anything
ojovivo
dirt enthusiast

★

shark vs the universe
Three Goblin Art

if i look back, i am lost

⁂
RMH
Aqua Utopia|海の底で記憶を紡ぐ
seen from Indonesia
seen from Indonesia

seen from Germany
seen from Spain
seen from Saudi Arabia
seen from Italy

seen from Malaysia
seen from Norway

seen from Türkiye
seen from Australia
seen from South Africa
seen from Switzerland
seen from United States

seen from Australia

seen from Malaysia
seen from United States
seen from Germany
seen from Norway

seen from Belgium

seen from Malaysia
@androidbits
Peter Tran's profile on Hashnode. Software Developer at GoPro
Trying out Hashnode’s Devblog, check me out over there: https://hashnode.com/@petertran

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Byobu and Screen
As I dive back into Linux userspace development I rediscovered Byobu and GNU Screen. These are terminal multiplexer tools, giving me tabs to different terminals plus session management.
Delivering results from Service to Activity
Activity creates Intent for Service and can insert ResultReceiver as Extra.
But what if Activity is stopped before result sent to RR?
Better to use LocalBroadcastManager
Here’s a good post on different ways to launch worker tasks: http://techtej.blogspot.com.es/2011/03/android-thread-constructspart-4.html?m=1
Same service defined in multiple apps
I have multiple apps using a service that is defined in a common SDK. So adding the service in each app's manifest uses the same package name.
This is fine because by default the interface to the service is not exported:
http://developer.android.com/guide/topics/manifest/service-element.html#exported
Cross-client Identity
After coding up some sample implementation I realize that the instructions for Cross-client Identity are actually two slightly different flows.
Both involve the Google auth server and your two clients, the Android app and the web app. The Android app is retrieving a piece of information from Google and forwarding it to the web app.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Removing ActionBar and Status bar
This will cause crash on orientation change on 4.2 and lower:
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
instead use
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getActionBar().hide();
Programmatic Orientation Change
Great for semi-automated testing:
private int mOrientationChangeCount; private Runnable mOrientationChangeRunnable = new Runnable() { @Override public void run() { Context context = getContext(); if (context instanceof Activity) { Activity activity = ((Activity)context); if ((++mOrientationChangeCount % 2) > 0) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } postDelayed(mOrientationChangeRunnable, 5000); } };
TestFlight Replacement
Publish to a shared Dropbox folder.
Google Play Services Library
From http://developer.android.com/google/play-services/setup.html
Make a copy of the Google Play services library project.
Note: If you are using Android Studio, skip this step.
Copy the library project at /extras/google/google_play_services/libproject/google-play-services_lib/ to the location where you maintain your Android app projects.
If you are using Eclipse, import the library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
GoogleApiClient
When using GoogleApiClient for the first time you will probably see the following logcat error:
GLSActivity(1108): [apc] Status from wire: INVALID_CLIENT_ID status: null GLSUser(1108): GLS error: INVALID_CLIENT_ID [email protected] oauth2:https://www.googleapis.com/auth/plus.login
Solution
In the Developer Console you need to manually enter a Consent message; see this StackOverflow answer.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Google+ Sign In
Getting started with Google+ integration:
https://developers.google.com/+/quickstart/android
Retrofit - Java REST Adapter
http://square.github.io/retrofit/
Manages the HTTP client
Marshals POJOs back and forth from JSON
Easy setting of OAuth2 tokens as a HTTP Authorization header
MediaCodec Stream Changes
Pre-4.4 KitKat there is a bug in MediaCodec ACodec.cpp that causes an native assertion when there is a stream change that causes internal port reconfiguration. One such change is a resolution change ie in H.264 SPS/PPS parameters.
This means the MediaCodec object needs to undergo teardown and re-setup, ie
mCodec.stop mCodec.release mCodec = MediaCodec.createDecoderBy... mCodec.configure mCodec.start
The trigger for this is to know when a resolution change is going to happen in the stream before the ES buffer is queued to the input. Therefore, the H.264 ES data needs to pre-parsed to examine SPS/PPS to detect the resolution change.
If the input is actually TS or PES then first parsing for start unit indicator will make this more efficient. Even better is if you know the beginning of the GOP.
Troubleshooting MediaCodec Output Buffers
A client retrieves a decoded output frame by calling MediaCodec.html.dequeueOutputBuffer. However, the ByteBuffer referred to may be null, empty or in a chipset-specific output format (see Andy McFadden's answer here).
So what if you need to examine the bytes of the decompressed frame, i.e. for a unit test? The answer lies in Andy McFadden's EncodecDecodeTest.java.
The frame needs to be rendered to a Surface (via MediaCodec.releaseOutputBuffer).
Read pixel values using GLES20.glReadPixels
Asserts in MediaExtractor
These asserts in production code are driving me crazy, had to write my own TS demuxer.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Parallel build jobs with NDK
ndk-build -j
The -j parameter also takes a integer value for the number parallel jobs if you don't want to saturate all your cores at once.
Low-latency with MediaCodec
Wrestling with MediaCodec to get good low-latency performance: http://stackoverflow.com/q/21440820/783051