Giter Club home page Giter Club logo

blogs's People

Contributors

zi6xuan avatar

blogs's Issues

PendingIntent可能出现push消息打开重建activity的问题

TaskStackBuilder stackBuilder = TaskStackBuilder.create(con);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
stackBuilder.getPendingIntent...

这样的模式为了创建完整的Activity队列,可能导致并不会调用已经存在的activity,而是重新创建,要想push消息等只调起已经存在的activity不要重新创建需要下面这样写:
PendingIntent resultPendingIntent = PendingIntent.getActivity(con, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.FLAG_UPDATE_CURRENT比较关键,如果不设置此值,会导致Intent消息不会更新到当前activity

android开发,全盘屏蔽状态栏和虚拟键问题

首先,原生android rom和厂家的开发板内置rom是不同的,会有一些定制功能和更多可控选项

  1. 利用android板开发展示类app时,需要完全全屏,而且要屏蔽其他按键。
  2. back键的屏蔽方式就不用说了
  • 重点在home键和recent
  1. home键屏蔽的方法是通过在activity声明加上
  <category android:name="android.intent.category.HOME" />
  <category android:name="android.intent.category.DEFAULT" />

来实现替换系统默认的home应用来达到目的,缺点是首次提示选择是否设置为默认home

  1. recent键的屏蔽方法是通过调用Activity的startLockTask();来达到锁定屏幕的效果,缺点是每次启动都会提示已经锁定屏幕,在锁定状态下,back和recent键都是屏蔽的
  • 其次还需要在activity的onCreate和onResume内调用如下代码来达到屏蔽部分设备可能出现的虚拟按键
        if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
            View v = act.getWindow().getDecorView();
            v.setSystemUiVisibility(View.GONE);
        } else if (Build.VERSION.SDK_INT >= 19) {
            //for new api versions.
            Window _window = act.getWindow();
            WindowManager.LayoutParams params = _window.getAttributes();
            params.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_FULLSCREEN;
            _window.setAttributes(params);
        }
  • 最后就是说明下,开发板厂家内置的rom系统一般是经过修改的,可能需要在设置->显示->关闭 状态栏隐藏后,是否允许手势调出状态栏注意此选项原生rom和部分rom可能不存在

Android API >=26处理push的方法

    private void sendPushNotic(Context con, String title, String content, String ext) {
        int id = getNoticatonId();
        NotificationCompat.Builder mBuilder = new NotificationCompat
                .Builder(con, NOTI_CHANNEL)
                .setSmallIcon(R.drawable.ic_launcher_foreground)
                .setContentTitle(title)
                .setAutoCancel(true)
                .setContentText(content);
        //
        Intent resultIntent = new Intent(con, NormalAct.class);
        resultIntent.putExtra("message", ext);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(con);
        stackBuilder.addParentStack(NormalAct.class);
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(
                id,
                PendingIntent.FLAG_UPDATE_CURRENT
        );
        NotificationManager mNotificationManager = (NotificationManager) con.getSystemService(Context.NOTIFICATION_SERVICE);
        assert mNotificationManager != null;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            if (mChannel == null) {
                mChannel = new NotificationChannel(NOTI_CHANNEL, con.getString(R.string.app_name), NotificationManager.IMPORTANCE_HIGH);
                // Configure the notification channel.
//            channel.setDescription("notification");
                mNotificationManager.createNotificationChannel(mChannel);
            }
        }
        mBuilder.setContentIntent(resultPendingIntent);
        mNotificationManager.notify(id, mBuilder.build());
    }

26及以上版本需要设置Channgle才能正常运作,而且只需要设置一次

RNRF-modal模式打开stack后,stack根节点pop两次才会返回的问题

        <Modal>
          <Stack hideNavBar={true}>
            <Drawer key='dwr' hideNavBar={true} contentComponent={MainDrawer}>
            </Drawer>
          </Stack>
          <Stack hideNavBar={true} key='login_all'>
            <Scene key='login' title={strings.login} hideNavBar={true} component={Login} />
          </Stack>
        </Modal>

上面代码,直接打开login的情况下,会导致pop时,根节点重复两次才能成功pop到dwr

Form::AddOwnedForm 方法说明

      Form^ ownedForm = gcnew Form;
      ownedForm->Text = "Owned Form";
      this->AddOwnedForm( ownedForm );
      ownedForm->Show();

以上代码中,ownedForm是this的附属窗体,ownedForm将不会显示在this后面,始终保持在this窗体前面显示

android EditText 转屏时setText无效

安卓会自动保存某些view的状态,旋转屏幕->onSaveInstanceState保存了EditText的内容->然后在onCreate的时候其实已经给EditText设置成功了,但是随后会在->onRestoreInstanceState尝试恢复之前的值,所以造成了值没改变。saveEnabled设为false就不会恢复这个EditText的值
android:saveEnabled="false"

apache授权目录外网正常访问配置

<Directory "${INSTALL_DIR}/www/mobile/">
    Options +FollowSymLinks +Multiviews
    AllowOverride all
    Require all granted
    Order allow,deny
    Allow from all
</Directory>

以上是授权一个目录外网访问配置,

# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>

<Directory "${INSTALL_DIR}/www/mobile/">
    Options +FollowSymLinks +Multiviews
    AllowOverride all
    Require all granted
    Order allow,deny
    Allow from all
</Directory>

</VirtualHost>
#Alias /mobile "F:\svn\AndroidDevelop\trunk\02.Code\02.Server\PhpServer\mobile/"

<VirtualHost *:9527>
  ServerName localhost:9527
  DocumentRoot "F:\svn\AndroidDevelop\trunk\02.Code\02.Server\PhpServer/"
  
<Directory "F:\svn\AndroidDevelop\trunk\02.Code\02.Server\PhpServer\mobile/">
    Options +FollowSymLinks +Multiviews
    AllowOverride all
    Require all granted
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

以上是通过虚拟主机,不同端口访问不同目录的配置

关于windows froms应用内嵌webbrowser显示google地图的问题

问题是这样婶的
windows froms应用内嵌webbrowser显示google地图,然后一般情况下没啥问题,使用起来美滋滋,但是有一天在一个windows触摸平板上测试的时候突然发现,双指捏合不能缩放地图,而且整个网页被放大缩小了。然后一顿查资料。

  • 调查JS,Html各种禁止缩放的手段
    <meta content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" name="viewport">
#map{            
        touch-action: none;
        -ms-touch-action: none;
}

别看了根本没用

  • 调查发现googleMap对浏览器兼容有差别

    支持的浏览器:
    当前版本的 Microsoft Edge (Windows)
    Internet Explorer 10 和 11 (Windows)
    当前版本和之前版本的 Firefox(Windows、macOS、Linux)
    当前版本和之前版本的 Chrome(Windows、macOS、Linux)
    当前版本和之前版本的 Safari (macOS)

  • 然后就一顿调查发现有人说webbrowser模式是IE7
    如果真的是这样的话,IE7肯定不行啊,然后就通过高打上的修改注册表实现强制使用最新版浏览器内核,安装测试,还是不行啊,FUCK,什么鬼,什么垃圾微软,什么垃圾IE。

  • 最后调查禁止浏览器缩放的方法
    最后找到通过修改组策略,禁止浏览器缩放页面,终于实现了这个问题,双指捏合的事件被正确的传递给googleMap处理缩放功能了,测试自带的IE浏览器页面缩放功能并没有受影响,不理解为什么双指捏合的事件浏览器优先级会高于googleMap

将Drawable转换为Bitmap

/**
     * 将Drawable转换为Bitmap,此函数针对一指定宽高的Drawable的组件或者
     * @param id 资源ID
     * @return Bitmap对象
     */
    public static Bitmap getBitmapDrawable(int id) {
        Drawable drawable = mContext.getResources().getDrawable(id);
        int w = drawable.getIntrinsicWidth();
        int h = drawable.getIntrinsicHeight();
        return getBitmapDrawableWH(id, w, h);
    }

    /**
     * 将Drawable转换为Bitmap,此函数针对未指定宽高的Drawable的组件或者
     * @param id 资源ID
     * @param width 指定的宽度
     * @param height 指定的高度
     * @return Bitmap对象
     */
    public static Bitmap getBitmapDrawableWH(int id, int width, int height) {
        Drawable drawable = mContext.getResources().getDrawable(id);
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return bitmap;
    }

此方法将指定的Drawable图元组件或者Image组件转换为Bitmap对象,图元组件不能通过getResources直接转换为Bitmap,欢迎讨论提问

VSCode调试PHP

官方文档地址
实际安装调试开发环境可以通过安装WAMP全家桶来搞定
我想说的是,我们安装的php环境里面可能默认没有这个东西

[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

一定要看仔细,这两个选项,必须是开启状态,尤其是remote_autostart,如果没有开启此选项,将不能自动开始调试

最简单的Property Animation

                final ScrollView sv = ((ScrollView) mTextView.getParent());
                int offset = mTextView.getMeasuredHeight() - sv.getHeight();
                if (offset < 0) {
                    offset = 0;
                }
                if (mScrollAni != null) {
                    mScrollAni.cancel();
                }
                mScrollAni = ValueAnimator.ofInt(sv.getScrollY(), offset).setDuration(800);
                mScrollAni.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        int offy = (int) animation.getAnimatedValue();
                        sv.scrollTo(0, offy);
                    }
                });
                mScrollAni.start();

通过属性动画(Property Animation)实现卷轴视图自动滚动动画
参考文献:http://blog.csdn.net/yanbober/article/details/46481171

修复React-native转换成纯pod依赖遇到的问题

将工程转换为纯pod有以下重要步骤:
1.首先初始化pod工程,这些就不赘述了,自行google
2.然后就是编辑podfile文件夹了,非常重要,文件如下:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'xxxxxx' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for xxxxxx
  rn_path = '../node_modules/react-native'
  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/"
  pod 'React', path: rn_path, subspecs: [
  'Core',
  'CxxBridge',
  'RCTBlob',
  'RCTActionSheet',
  'RCTAnimation',
  'RCTGeolocation',
  'RCTImage',
  'RCTLinkingIOS',
  'RCTNetwork',
  'RCTSettings',
  'RCTText',
  'RCTVibration',
  'RCTWebSocket'
  ]
  pod 'IQKeyboardManager' #iOS8 and later
  
  pod 'react-native-cookies', :path => '../node_modules/react-native-cookies/ios'

  pod 'react-native-fast-image', :path => '../node_modules/react-native-fast-image'
  
  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
  
  pod 'RNSVG', :path => '../node_modules/react-native-svg'

  pod 'react-native-video', :path => '../node_modules/react-native-video'

  pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

  pod 'RNImageCropPicker', :path => '../node_modules/react-native-image-crop-picker'

  target 'xxxxxxTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'xxxxxx-tvOS' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for xxxxxx-tvOS

  target 'xxxxxx-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

下面这部分依赖基本是就是React核心库部分的东西,如果和自己本身的工程有差异可以对比检查修改下,
这里面添加的工程路径就是物理路径,而模块名字则是对应目录下的xxx.podspec文件的名字,其他的就是自己用到的依赖库了。
podfile改完记得pod install,还要记得删除原来libs引用方式的工程文件

 rn_path = '../node_modules/react-native'
 pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/"
 pod 'React', path: rn_path, subspecs: [
 'Core',
 'CxxBridge',
 'RCTBlob',
 'RCTActionSheet',
 'RCTAnimation',
 'RCTGeolocation',
 'RCTImage',
 'RCTLinkingIOS',
 'RCTNetwork',
 'RCTSettings',
 'RCTText',
 'RCTVibration',
 'RCTWebSocket'
 ]

莫名其妙找不到JS库facebook/react-native#14749 (comment)
在React集成库里面添加BatchedBridgeCxxBridge这个就可以了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.