24
Android hide An unknown features

Android hide

Embed Size (px)

DESCRIPTION

Android hint feeatures that no all developeres know, and probably they should.

Citation preview

Page 1: Android hide

Android hide

An unknown features

Page 2: Android hide

About Me

Android developer

● Wordline● Catmóbil

SCP

● Catdroid

@lepetitbernat

http://es.linkedin.com/in/bernatp

Page 3: Android hide

About speech

Restricted profiles-> JellyBean+

Crash reports-> ApplicationErrorReport

-> Send Feedback (2 ways)

Hide intents-> Data usage

Page 4: Android hide

Restricted profiles

Added in JellyBean• Android 4.3

• API 18+

• Tablets

Page 5: Android hide

Restrictions

TYPE_BOOLEAN

TYPE_CHOICE

TYPE_MULTI_SELECT

BroadcastReceiverIntentFilter

android.intent.action.

GET_RESTRICTION_ENTRIES

Page 6: Android hide

extends BroadCastReceiver {

onReceive(...)

PendingResult result = goAsync();

new Thread()

run()

// ADD RESTRICTIONS

CODE! Create broadcast

Page 7: Android hide

new ArrayList<RestrictionEntry>();

new RestrictionEntry(KEY_BOOLEAN, true);

entry.setTitle("Dangerous enabled");

entry.setType(RestrictionEntry.TYPE_BOOLEAN);

add(entry);

CODE! Create restrictions

Page 8: Android hide

CODE!

Bundle extras = new Bundle();

extras.putParcelableArrayList(

Intent.EXTRA_RESTRICTIONS_LIST, restrictions);

result.setResult(Activity.RESULT_OK, null, extras);

result.finish();

Final steps!

Page 9: Android hide

UserManager usrManager = (UserManager)

getSystemService(Context.USER_SERVICE);

Bundle restrictions =

usrManager.getApplicationRestrictions(getPackageName());

restrictions != null

restrictions.get(...);

CODE! Using restrictions

Page 10: Android hide

Restrictions

Not enough?

Page 11: Android hide

Intent customIntent = new Intent();

customIntent.setClass(context, SettingsActivity.class);

extras.putParcelable(

Intent.EXTRA_RESTRICTIONS_INTENT, customIntent);

result.setResult(Activity.RESULT_OK, null, extras);

result.finish();

CODE! Custom restrictions

Page 12: Android hide

Links

• d.android.como http://goo.gl/I0D3PU

• DevByteso https://www.youtube.com/watch?

v=pdUcANNm72o

Page 13: Android hide

Crash reports

Added in IceCream• Android 4.0

• API 14+

• Leave user write messages

Page 14: Android hide

Crash reports

Page 15: Android hide

Crash reports

ApplicationErrorReport

• TYPE_NONE

• TYPE_CRASH

• TYPE_ANR

• TYPE_BATTERY

• TYPE_RUNNING_SERVICE

Page 16: Android hide

Exception e;

...

report = new ApplicationErrorReport();

report.type = ApplicationErrorReport.TYPE_CRASH;

...

crash= new ApplicationErrorReport.CrashInfo();

report.crashInfo = crash;

...

arn = new ApplicationErrorReport.AnrInfo();

report.arnInfo = arn;

CODE! ApplicationErrorReport

Page 17: Android hide

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setClassName("com.google.android.feedback",

"com.google.android.feedback.FeedbackActivity");

intent.putExtra(Intent.EXTRA_BUG_REPORT, report)

startActivity(intent);

CODE! Intent

Page 18: Android hide

Crash reports

Intent.EXTRA_BUG_REPORT

Intent.ACTION_APP_ERROR

Page 19: Android hide

CODE! Trick

FeedbackException

● Custom message● Custom class name● Custom stacktrace

● User messages

Page 20: Android hide

Links

• d.android.como http://goo.gl/QZnjZW

• Black feedbacko http://stackoverflow.com/a/20848542

• Google feedbacko http://stackoverflow.com/a/22156938

Page 21: Android hide

Data usage

Page 22: Android hide

IntentFilter

android.intent.action.

MANAGE_NETWORK_USAGE

CODE! ApplicationErrorReport

Page 23: Android hide

Questions

?

Page 24: Android hide

Thanks

!https://github.com/alorma/Baug_Android_hide