android-获取手机小区信息界面设计

1. manifests

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.npsmaster.phoneinfo">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
    </uses-permission>
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" >
    </uses-permission>
</manifest>
2.main
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.npsmaster.phoneinfo.MainActivity">
<!--start-->
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/childlayout"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ffcccccc"
            android:layout_margin="1dp">
            <!-- line1 -->
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="20dp"
                android:background="#ffcccccc"
                android:layout_margin="0.5dp">

                <TextView
                    android:text="General Information"
                    android:layout_marginTop="5dp"
                    android:layout_width="0.0dp"
                    android:layout_height="20dp"
                    android:layout_weight="1"
                    android:id="@+id/tvStaticInfoLable">
                </TextView>
                <TextView
                    android:text="Time:"
                    android:layout_marginTop="5dp"
                    android:layout_width="0.0dp"
                    android:layout_height="20dp"
                    android:layout_weight="1"
                    android:id="@+id/tvTimeleaps">
                </TextView>
            </TableRow>
            <!--line2-->
            <TableRow
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
作为AI语言模型,我无法直接获取手机的实时信息。但是,下面提供一种获取当前界面截图的方法,可以通过截图得到当前界面的内容。 1. 添加权限 在 AndroidManifest.xml 文件中添加以下权限: ```xml <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> ``` 2. 创建截图方法 ```java public static Bitmap captureScreen(Activity activity) { View view = activity.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bmp = view.getDrawingCache(); int statusBarHeight = getStatusBarHeight(activity); int width = activity.getWindowManager().getDefaultDisplay().getWidth(); int height = activity.getWindowManager().getDefaultDisplay().getHeight(); Bitmap screenshot = Bitmap.createBitmap(bmp, 0, statusBarHeight, width, height - statusBarHeight); view.destroyDrawingCache(); return screenshot; } private static int getStatusBarHeight(Activity activity) { int result = 0; int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = activity.getResources().getDimensionPixelSize(resourceId); } return result; } ``` 3. 调用截图方法 在需要获取当前界面内容的地方调用截图方法即可: ```java Bitmap screenshot = captureScreen(activity); ``` 4. 保存截图 可以将截图保存到本地,以便查看: ```java FileOutputStream fos = null; File file = new File(Environment.getExternalStorageDirectory() + "/screenshot.png"); try { fos = new FileOutputStream(file); screenshot.compress(Bitmap.CompressFormat.PNG, 100, fos); fos.flush(); } catch (IOException e) { e.printStackTrace(); } finally { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值