Android Small Knowledge Slice

Source: Internet
Author: User

1, TextView the content is too long to omit and scroll

Android:singleline= "true",//single line

Android:ellipsize= "",//Start middle end omitted position

Android:marqueerepeatlimit= ""//Marquee marquee Marquee_forever keep rolling

2, call the system comes with the tool transfer files

Intent.setaction (intent.action_send). SetType ("*/*"). PutExtra (Intent.extra_stream, Uri.fromfile (file)).

Call Bluetooth transfer:

Setaction (Intent.action_bluetooth);

3, Intent

  Explicit intent: Implemented by specifying the name of the intent component, which is typically implemented within the same application, with the knowledge of the target component name .

implicit intent: implemented by intent filter, which is generally used without explicitly stating the name of the target component, and is generally intended for use in different applications Room.

The Settype and SetData methods will clear each other, and Android provides a Setdataandtype () method to solve

View Plaincopy to Clipboardprint?
    1. Public Intent setData (Uri data) {
    2. Mdata = data;
    3. Mtype = null;
    4. return this;
    5. }
View Plain
    1. Public Intent setType (String type) {
    2. Mdata = null;
    3. Mtype = type;
    4. return this;
    5. }

4, ActionBar:
Setdisplayhomeasupenabled (Boolean enable) displays the return icon
public boolean onoptionsitemselected (MenuItem item) {
Case Android. R.id.home:

Setdisplayshowtitileenabled () ...


5. Custom theme:
Android:elevation Actionbar The width of the shadow @null No
Android:colorprimarydark Screen Top status bar
Android:homeasupindicator Actionbar return arrow @drawable/IC_ARROW_BACK_24DP
Android:actionoverflowbuttonstyle ActionBar

<!--Action Bar overflow menu icon. -
<style name= "Blacklistactionbaroverflowqp" parent= "@android: Style/widget.material.light.actionbutton.overflow ">
<item name= "Android:src" > @drawable/ic_menu_overflow_lt</item>
</style>


6. Androidxliff XML Localization interchange File format:xml Local Data Interchange Format

<resources xmlns:xliff= "urn:oasis:names:tc:xliff:document:1.2" >
<string name= "Mms_size_expiry" > "Message size:& #160; <xliff:g id=" COUNT ">%1$d</xliff:g>&# 160; kb,& #160;& #160;& #160; expires:& #160; <xliff:g id= "Time" >%2$s</xliff:g> "</string>

Mcontext.getstring (r.string.mms_size_expiry, size, expiry)

%n$s N represents the first few arguments, S is the string
%n$ms m represents the total length, if the string length is greater than M, the string is displayed, if less than the number of spaces after the string is displayed
%N$MD m Fill 0
%N$MF m=2.3 Format 00.000


7. Get permission for SMS operation:
Android5.0 for text message insertion and modification permissions to control, only the system default SMS app to operate the SMS. Rights Management classes:

Appopsmanager.java  appopsservice.java//get permission: Packagemanager Packagemanager = Context.getpackagemanager (); Appopsmanager Appopsmanager = (appopsmanager) context.getsystemservice (Context.app_ops_service); PackageInfo info = packagemanager.getpackageinfo (package_name, packagemanager.get_uninstalled_packages); Boolean isignored = appopsmanager.mode_ignored = = Appopsmanager.checkop (appopsmanager.op_write_sms, Info.applicationInfo.uid, package_name); if (isignored) {   //Turn on   appopsmanager.setmode (appopsmanager.op_ Write_sms, Info.applicationInfo.uid, Package_name, appopsmanager.mode_allowed);} if (isignored) {   //off   Appopsmanager.setmode (appopsmanager.op_write_sms, Info.applicationInfo.uid, Package_ NAME, appopsmanager.mode_ignored);} Permission,    <uses-permission android:name= "Android.permission.UPDATE_APP_OPS_STATS"/>

8. Change the system default SMS app:
Intent Intent = new Intent (Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT) Intent.putextra (Telephony.Sms.Intents.EXTRA _package_name, Selfpackagename); startactivity (intent); Telephony.Sms.getDefaultSmsPackage (Context context)  //Get the default SMS app PackageName




Android Small Knowledge Slice

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.