android hide

Post on 06-May-2015

105 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

Android hide

An unknown features

About Me

Android developer

● Wordline● Catmóbil

SCP

● Catdroid

@lepetitbernat

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

About speech

Restricted profiles-> JellyBean+

Crash reports-> ApplicationErrorReport

-> Send Feedback (2 ways)

Hide intents-> Data usage

Restricted profiles

Added in JellyBean• Android 4.3

• API 18+

• Tablets

Restrictions

TYPE_BOOLEAN

TYPE_CHOICE

TYPE_MULTI_SELECT

BroadcastReceiverIntentFilter

android.intent.action.

GET_RESTRICTION_ENTRIES

extends BroadCastReceiver {

onReceive(...)

PendingResult result = goAsync();

new Thread()

run()

// ADD RESTRICTIONS

CODE! Create broadcast

new ArrayList<RestrictionEntry>();

new RestrictionEntry(KEY_BOOLEAN, true);

entry.setTitle("Dangerous enabled");

entry.setType(RestrictionEntry.TYPE_BOOLEAN);

add(entry);

CODE! Create restrictions

CODE!

Bundle extras = new Bundle();

extras.putParcelableArrayList(

Intent.EXTRA_RESTRICTIONS_LIST, restrictions);

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

result.finish();

Final steps!

UserManager usrManager = (UserManager)

getSystemService(Context.USER_SERVICE);

Bundle restrictions =

usrManager.getApplicationRestrictions(getPackageName());

restrictions != null

restrictions.get(...);

CODE! Using restrictions

Restrictions

Not enough?

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

Links

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

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

v=pdUcANNm72o

Crash reports

Added in IceCream• Android 4.0

• API 14+

• Leave user write messages

Crash reports

Crash reports

ApplicationErrorReport

• TYPE_NONE

• TYPE_CRASH

• TYPE_ANR

• TYPE_BATTERY

• TYPE_RUNNING_SERVICE

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

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

Crash reports

Intent.EXTRA_BUG_REPORT

Intent.ACTION_APP_ERROR

CODE! Trick

FeedbackException

● Custom message● Custom class name● Custom stacktrace

● User messages

Links

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

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

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

Data usage

IntentFilter

android.intent.action.

MANAGE_NETWORK_USAGE

CODE! ApplicationErrorReport

Questions

?

Thanks

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

top related