返回顶部
首页 > 资讯 > 移动开发 >Android VideoView类实例讲解
  • 719
分享到

Android VideoView类实例讲解

videoviewAndroid 2022-06-06 07:06:01 719人浏览 独家记忆
摘要

        本节使用系统的示例类VideoView继续SurfaceView类相关内容的讲解

        本节使用系统的示例类VideoView继续SurfaceView类相关内容的讲解,以让大家能更深入理解Android系统中图形绘制基础类的实现原理。也许你会发现无法改变VideoView类的控制方面,我们可以通过重构VideoView类来实现更加个性化的播放器。

         下面是VideoView类的相关代码。

Java 代码


 public class VideoView extends SurfaceView implements MediaPlayerControl { 
 private String TAG = "VideoView"; 
 // settable by the client 
 private Uri   mUri; 
 private int   mDuration; 
 // all possible internal states 
 private static final int STATE_ERROR    = -1; 
 private static final int STATE_IDLE    = 0; 
 private static final int STATE_PREPARING   = 1; 
 private static final int STATE_PREPARED   = 2; 
 private static final int STATE_PLAYING   = 3; 
 private static final int STATE_PAUSED    = 4; 
 private static final int STATE_PLAYBACK_COMPLETED = 5; 
 // mCurrentState is a VideoView object's current state. 
 // mTargetState is the state that a method caller intends to reach. 
 // For instance, regardless the VideoView object's current state, 
 // calling pause() intends to bring the object to a target state 
 // of STATE_PAUSED. 
 private int mCurrentState = STATE_IDLE; 
 private int mTargetState = STATE_IDLE; 
 // All the stuff we need for playing and showing a video 
 private SurfaceHolder mSurfaceHolder = null; 
 private MediaPlayer mMediaPlayer = null; 
 private int   mVideoWidth; 
 private int   mVideoHeight; 
 private int   mSurfaceWidth; 
 private int   mSurfaceHeight; 
 private MediaController mMediaController; 
 private OnCompletionListener mOnCompletionListener; 
 private MediaPlayer.OnPreparedListener mOnPreparedListener; 
 private int   mCurrentBufferPercentage; 
 private OnErrorListener mOnErrorListener; 
 private int   mSeekWhenPrepared; // recording the seek position while preparing 
 private boolean  mCanPause; 
 private boolean  mCanSeekBack; 
 private boolean  mCanSeekForward; 
 public VideoView(Context context) { 
  super(context); 
  initVideoView(); 
 } 
 public VideoView(Context context, AttributeSet attrs) { 
  this(context, attrs, 0); 
  initVideoView(); 
 } 
 public VideoView(Context context, AttributeSet attrs, int defStyle) { 
  super(context, attrs, defStyle); 
  initVideoView(); 
 } 
 @Override 
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
  //Log.i("@@@@", "onMeasure"); 
  int width = getDefaultSize(mVideoWidth, widthMeasureSpec); 
  int height = getDefaultSize(mVideoHeight, heightMeasureSpec); 
  if (mVideoWidth > 0 && mVideoHeight > 0) { 
   if ( mVideoWidth * height > width * mVideoHeight ) { 
    //Log.i("@@@", "image too tall, correcting"); 
    height = width * mVideoHeight / mVideoWidth; 
   } else if ( mVideoWidth * height < width * mVideoHeight ) { 
    //Log.i("@@@", "image too wide, correcting"); 
    width = height * mVideoWidth / mVideoHeight; 
   } else { 
    //Log.i("@@@", "aspect ratio is correct: " + 
      //width+"/"+height+"="+ 
      //mVideoWidth+"/"+mVideoHeight); 
   } 
  } 
  //Log.i("@@@@@@@@@@", "setting size: " + width + 'x' + height); 
  setMeasuredDimension(width, height); 
 } 
 public int resolveAdjustedSize(int desiredSize, int measureSpec) { 
  int result = desiredSize; 
  int specMode = MeasureSpec.getMode(measureSpec); 
  int specSize = MeasureSpec.getSize(measureSpec); 
  switch (specMode) { 
   case MeasureSpec.UNSPECIFIED: 
        result = desiredSize; 
    break; 
   case MeasureSpec.AT_MOST: 
     
    result = Math.min(desiredSize, specSize); 
    break; 
   case MeasureSpec.EXACTLY: 
    // No choice. Do what we are told. 
    result = specSize; 
    break; 
  } 
  return result; 
} 
 private void initVideoView() { 
  mVideoWidth = 0; 
  mVideoHeight = 0; 
  getHolder().addCallback(mSHCallback); 
  getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); 
  setFocusable(true); 
  setFocusableInTouchMode(true); 
  requestFocus(); 
  mCurrentState = STATE_IDLE; 
  mTargetState = STATE_IDLE; 
 } 
 public void setVideoPath(String path) { 
  setVideoURI(Uri.parse(path)); 
 } 
 public void setVideoURI(Uri uri) { 
  mUri = uri; 
  mSeekWhenPrepared = 0; 
  openVideo(); 
  requestLayout(); 
  invalidate(); 
 } 
 public void stopPlayback() { 
  if (mMediaPlayer != null) { 
   mMediaPlayer.stop(); 
   mMediaPlayer.release(); 
   mMediaPlayer = null; 
   mCurrentState = STATE_IDLE; 
   mTargetState = STATE_IDLE; 
  } 
 } 
 private void openVideo() { 
  if (mUri == null || mSurfaceHolder == null) { 
   // not ready for playback just yet, will try again later 
   return; 
  } 
  // Tell the music playback service to pause 
  // TODO: these constants need to be published somewhere in the framework. 
  Intent i = new Intent("com.android.music.musicservicecommand"); 
  i.putExtra("command", "pause"); 
  mContext.sendBroadcast(i); 
  // we shouldn't clear the target state, because somebody might have 
  // called start() previously 
  release(false); 
  try { 
   mMediaPlayer = new MediaPlayer(); 
   mMediaPlayer.setOnPreparedListener(mPreparedListener); 
   mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener); 
   mDuration = -1; 
   mMediaPlayer.setOnCompletionListener(mCompletionListener); 
   mMediaPlayer.setOnErrorListener(mErrorListener); 
   mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener); 
   mCurrentBufferPercentage = 0; 
   mMediaPlayer.setDataSource(mContext, mUri); 
   mMediaPlayer.setDisplay(mSurfaceHolder); 
   mMediaPlayer.setAudiOStreamType(AudioManager.STREAM_MUSIC); 
   mMediaPlayer.setScreenOnWhilePlaying(true); 
   mMediaPlayer.prepareAsync(); 
   // we don't set the target state here either, but preserve the 
   // target state that was there before. 
   mCurrentState = STATE_PREPARING; 
   attachMediaController(); 
  } catch (IOException ex) { 
   Log.w(TAG, "Unable to open content: " + mUri, ex); 
   mCurrentState = STATE_ERROR; 
   mTargetState = STATE_ERROR; 
   mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0); 
   return; 
  } catch (IllegalArgumentException ex) { 
   Log.w(TAG, "Unable to open content: " + mUri, ex); 
   mCurrentState = STATE_ERROR; 
   mTargetState = STATE_ERROR; 
   mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0); 
   return; 
  } 
 } 
 public void setMediaController(MediaController controller) { 
  if (mMediaController != null) { 
   mMediaController.hide(); 
  } 
  mMediaController = controller; 
  attachMediaController(); 
 } 
 private void attachMediaController() { 
  if (mMediaPlayer != null && mMediaController != null) { 
   mMediaController.setMediaPlayer(this); 
   View anchorView = this.getParent() instanceof View ? 
     (View)this.getParent() : this; 
   mMediaController.setAnchorView(anchorView); 
   mMediaController.setEnabled(isInPlaybackState()); 
  } 
 } 
 MediaPlayer.OnVideoSizeChangedListener mSizeChangedListener = 
  new MediaPlayer.OnVideoSizeChangedListener() { 
   public void onVideoSizeChanged(MediaPlayer mp, int width, int height) { 
    mVideoWidth = mp.getVideoWidth(); 
    mVideoHeight = mp.getVideoHeight(); 
    if (mVideoWidth != 0 && mVideoHeight != 0) { 
     getHolder().setFixedSize(mVideoWidth, mVideoHeight); 
    } 
   } 
 }; 
 MediaPlayer.OnPreparedListener mPreparedListener = new MediaPlayer.OnPreparedListener() { 
  public void onPrepared(MediaPlayer mp) { 
   mCurrentState = STATE_PREPARED; 
   // Get the capabilities of the player for this stream 
   Metadata data = mp.getMetadata(MediaPlayer.METADATA_ALL, 
          MediaPlayer.BYPASS_METADATA_FILTER); 
   if (data != null) { 
    mCanPause = !data.has(Metadata.PAUSE_AVAILABLE) 
      || data.getBoolean(Metadata.PAUSE_AVAILABLE); 
    mCanSeekBack = !data.has(Metadata.SEEK_BACKWARD_AVAILABLE) 
      || data.getBoolean(Metadata.SEEK_BACKWARD_AVAILABLE); 
    mCanSeekForward = !data.has(Metadata.SEEK_FORWARD_AVAILABLE) 
      || data.getBoolean(Metadata.SEEK_FORWARD_AVAILABLE); 
   } else { 
    mCanPause = mCanSeekForward = mCanSeekForward = true; 
   } 
   if (mOnPreparedListener != null) { 
    mOnPreparedListener.onPrepared(mMediaPlayer); 
   } 
   if (mMediaController != null) { 
    mMediaController.setEnabled(true); 
   } 
   mVideoWidth = mp.getVideoWidth(); 
   mVideoHeight = mp.getVideoHeight(); 
   int seekToPosition = mSeekWhenPrepared; // mSeekWhenPrepared may be changed after seekTo() call 
   if (seekToPosition != 0) { 
    seekTo(seekToPosition); 
   } 
   if (mVideoWidth != 0 && mVideoHeight != 0) { 
    //Log.i("@@@@", "video size: " + mVideoWidth +"/"+ mVideoHeight); 
    getHolder().setFixedSize(mVideoWidth, mVideoHeight); 
    if (mSurfaceWidth == mVideoWidth && mSurfaceHeight == mVideoHeight) { 
     // We didn't actually change the size (it was already at the size 
     // we need), so we won't get a "surface changed" callback, so 
     // start the video here instead of in the callback. 
     if (mTargetState == STATE_PLAYING) { 
      start(); 
      if (mMediaController != null) { 
       mMediaController.show(); 
      } 
     } else if (!isPlaying() && 
        (seekToPosition != 0 || getCurrentPosition() > 0)) { 
      if (mMediaController != null) { 
       // Show the media controls when we're paused into a video and make 'em stick. 
       mMediaController.show(0); 
      } 
     } 
    } 
   } else { 
    // We don't know the video size yet, but should start anyway. 
    // The video size might be reported to us later. 
    if (mTargetState == STATE_PLAYING) { 
     start(); 
    } 
   } 
  } 
 }; 
 private MediaPlayer.OnCompletionListener mCompletionListener = 
  new MediaPlayer.OnCompletionListener() { 
  public void onCompletion(MediaPlayer mp) { 
   mCurrentState = STATE_PLAYBACK_COMPLETED; 
   mTargetState = STATE_PLAYBACK_COMPLETED; 
   if (mMediaController != null) { 
    mMediaController.hide(); 
   } 
   if (mOnCompletionListener != null) { 
    mOnCompletionListener.onCompletion(mMediaPlayer); 
   } 
  } 
 }; 
 private MediaPlayer.OnErrorListener mErrorListener = 
  new MediaPlayer.OnErrorListener() { 
  public boolean onError(MediaPlayer mp, int framework_err, int impl_err) { 
   Log.d(TAG, "Error: " + framework_err + "," + impl_err); 
   mCurrentState = STATE_ERROR; 
   mTargetState = STATE_ERROR; 
   if (mMediaController != null) { 
    mMediaController.hide(); 
   } 
    
   if (mOnErrorListener != null) { 
    if (mOnErrorListener.onError(mMediaPlayer, framework_err, impl_err)) { 
     return true; 
    } 
   } 
    
   if (getWindowToken() != null) { 
    Resources r = mContext.getResources(); 
    int messageId; 
    if (framework_err == MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) { 
     messageId = com.android.internal.R.string.VideoView_error_text_invalid_progressive_playback; 
    } else { 
     messageId = com.android.internal.R.string.VideoView_error_text_unknown; 
    } 
    new AlertDialog.Builder(mContext) 
      .setTitle(com.android.internal.R.string.VideoView_error_title) 
      .setMessage(messageId) 
      .setPositiveButton(com.android.internal.R.string.VideoView_error_button, 
        new DialogInterface.OnClickListener() { 
         public void onClick(DialogInterface dialog, int whichButton) { 
           
          if (mOnCompletionListener != null) { 
           mOnCompletionListener.onCompletion(mMediaPlayer); 
          } 
         } 
        }) 
      .setCancelable(false) 
      .show(); 
   } 
   return true; 
  } 
 }; 
 private MediaPlayer.OnBufferingUpdateListener mBufferingUpdateListener = 
  new MediaPlayer.OnBufferingUpdateListener() { 
  public void onBufferingUpdate(MediaPlayer mp, int percent) { 
   mCurrentBufferPercentage = percent; 
  } 
 }; 
  
 public void setOnPreparedListener(MediaPlayer.OnPreparedListener l) 
 { 
  mOnPreparedListener = l; 
 } 
  
 public void setOnCompletionListener(OnCompletionListener l) 
 { 
  mOnCompletionListener = l; 
 } 
  
 public void setOnErrorListener(OnErrorListener l) 
 { 
  mOnErrorListener = l; 
 } 
 SurfaceHolder.Callback mSHCallback = new SurfaceHolder.Callback() 
 { 
  public void surfaceChanged(SurfaceHolder holder, int fORMat, 
         int w, int h) 
  { 
   mSurfaceWidth = w; 
   mSurfaceHeight = h; 
   boolean isValidState = (mTargetState == STATE_PLAYING); 
   boolean hasValidSize = (mVideoWidth == w && mVideoHeight == h); 
   if (mMediaPlayer != null && isValidState && hasValidSize) { 
    if (mSeekWhenPrepared != 0) { 
     seekTo(mSeekWhenPrepared); 
    } 
    start(); 
    if (mMediaController != null) { 
     mMediaController.show(); 
    } 
   } 
  } 
  public void surfaceCreated(SurfaceHolder holder) 
  { 
   mSurfaceHolder = holder; 
   openVideo(); 
  } 
  public void surfaceDestroyed(SurfaceHolder holder) 
  { 
   // after we return from this we can't use the surface any more 
   mSurfaceHolder = null; 
   if (mMediaController != null) mMediaController.hide(); 
   release(true); 
  } 
 }; 
  private void release(boolean cleartargetstate) { 
  if (mMediaPlayer != null) { 
   mMediaPlayer.reset(); 
   mMediaPlayer.release(); 
   mMediaPlayer = null; 
   mCurrentState = STATE_IDLE; 
   if (cleartargetstate) { 
    mTargetState = STATE_IDLE; 
   } 
  } 
 } 
 @Override 
 public boolean onTouchEvent(MotionEvent ev) { 
  if (isInPlaybackState() && mMediaController != null) { 
   toggleMediaControlsVisiblity(); 
  } 
  return false; 
 } 
 @Override 
 public boolean onTrackballEvent(MotionEvent ev) { 
  if (isInPlaybackState() && mMediaController != null) { 
   toggleMediaControlsVisiblity(); 
  } 
  return false; 
 } 
 @Override 
 public boolean onKeyDown(int keyCode, KeyEvent event) 
 { 
  boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && 
          keyCode != KeyEvent.KEYCODE_VOLUME_UP && 
          keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && 
          keyCode != KeyEvent.KEYCODE_MENU && 
          keyCode != KeyEvent.KEYCODE_CALL && 
          keyCode != KeyEvent.KEYCODE_ENDCALL; 
  if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) { 
   if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || 
     keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { 
    if (mMediaPlayer.isPlaying()) { 
     pause(); 
     mMediaController.show(); 
    } else { 
     start(); 
     mMediaController.hide(); 
    } 
    return true; 
   } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP 
     && mMediaPlayer.isPlaying()) { 
    pause(); 
    mMediaController.show(); 
   } else { 
    toggleMediaControlsVisiblity(); 
   } 
  } 
  return super.onKeyDown(keyCode, event); 
 } 
 private void toggleMediaControlsVisiblity() { 
  if (mMediaController.isshowing()) { 
   mMediaController.hide(); 
  } else { 
   mMediaController.show(); 
  } 
 } 
 public void start() { 
  if (isInPlaybackState()) { 
   mMediaPlayer.start(); 
   mCurrentState = STATE_PLAYING; 
  } 
  mTargetState = STATE_PLAYING; 
 } 
 public void pause() { 
  if (isInPlaybackState()) { 
   if (mMediaPlayer.isPlaying()) { 
    mMediaPlayer.pause(); 
    mCurrentState = STATE_PAUSED; 
   } 
  } 
  mTargetState = STATE_PAUSED; 
 } 
 // cache duration as mDuration for faster access 
 public int getDuration() { 
  if (isInPlaybackState()) { 
   if (mDuration > 0) { 
    return mDuration; 
   } 
   mDuration = mMediaPlayer.getDuration(); 
   return mDuration; 
  } 
  mDuration = -1; 
  return mDuration; 
 } 
 public int getCurrentPosition() { 
  if (isInPlaybackState()) { 
   return mMediaPlayer.getCurrentPosition(); 
  } 
  return 0; 
 } 
 public void seekTo(int msec) { 
  if (isInPlaybackState()) { 
   mMediaPlayer.seekTo(msec); 
   mSeekWhenPrepared = 0; 
  } else { 
   mSeekWhenPrepared = msec; 
  } 
 }  
 public boolean isPlaying() { 
  return isInPlaybackState() && mMediaPlayer.isPlaying(); 
 } 
 public int getBufferPercentage() { 
  if (mMediaPlayer != null) { 
   return mCurrentBufferPercentage; 
  } 
  return 0; 
 } 
 private boolean isInPlaybackState() { 
  return (mMediaPlayer != null && 
    mCurrentState != STATE_ERROR && 
    mCurrentState != STATE_IDLE && 
    mCurrentState != STATE_PREPARING); 
 } 
 public boolean canPause() { 
  return mCanPause; 
 } 
 public boolean canSeekBackward() { 
  return mCanSeekBack; 
 } 
 public boolean canSeekForward() { 
  return mCanSeekForward; 
 } 
} 

       以上就是对Android VideoView 类的详细介绍,后续继续补充相关知识,谢谢大家对本站的支持!

您可能感兴趣的文章:android视频播放简单实现示例(VideoView&MediaPlayer)Android videoview抢占焦点的处理方法android之视频播放系统VideoView和自定义VideoView控件的应用Android编程实现VideoView循环播放功能的方法Android多媒体之VideoView视频播放器Android使用VideoView播放本地视频和网络视频的方法详解Android App中使用VideoView来实现视频播放的方法Android自定义播放器控件VideoViewandroid使用videoview播放视频android多媒体类VideoView使用方法详解


--结束END--

本文标题: Android VideoView类实例讲解

本文链接: https://lsjlt.com/news/24220.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • Android VideoView类实例讲解
            本节使用系统的示例类VideoView继续SurfaceView类相关内容的讲解...
    99+
    2022-06-06
    videoview Android
  • JavaScriptClass类实例讲解
    目录Class类初识classclass中getter和setter设置表达式方式书写静态属性与静态方法私有属性和私有方法class继承静态属性和方法继承私有属性和方法继承class...
    99+
    2022-11-13
    JavaScript Class类 JS Class类
  • android多媒体类VideoView使用方法详解
    一、概述VideoView类将视频的显示和控制集于一身,我们可以借助它完成一个简易的视频播放器。VideoView和MediaPlayer也比较相似。二、VideoView的使用方法它主要有以下几种常用方法步骤:指定视频文件的路径,2.接下...
    99+
    2023-05-30
    android 多媒体类 videoview
  • android视频播放简单实现示例(VideoView&MediaPlayer)
    如果你看过我的《android音乐播放简单实现(MediaPlayer)》,那么本篇将会毫无压力。首先是主界面的三个按钮和一个播放控件<?xml version="1.0" encoding="utf-8"?>&...
    99+
    2023-05-30
    android 视频播放 roi
  • TypeScript中class类型实例讲解
    目录class类型构造函数class类的继承可见修饰符只读修饰符总结class类型 TypeScript支持ES引入的class关键字,并为其添加了类型注解和其他语法(例如:可见性修...
    99+
    2022-12-30
    typescript class类型参数 typescript的类型 typescript class
  • Android中SharedPreference使用实例讲解
    SharedPreference方面的内容还算是比较简单易懂的,在此还是主要贴上效果与代码,最后也是附上源码。 首先是输入账号admin,密码123,选择记住密码登陆。 登陆后...
    99+
    2022-06-06
    Android
  • 关于random类与scanner类的实例讲解
    生成指定范围内的随机数Math.random() 生成随机数,随机数在0到1之间,类型是 double。代码示例:public class randCase { public static void main(String[] ar...
    99+
    2021-08-21
    java入门 random scanner 实例 讲解
  • Android ListView 实例讲解清晰易懂
    一、前言 在某些场景下,单一文字的ListView Item已不适合当前需求,因此需要我们自定义Item布局来满足需求。下面我们来实现一个带图标和文字的Item。 二、代码展示 1....
    99+
    2024-04-02
  • Java异常 Exception类及其子类(实例讲解)
    C语言时用if...else...来控制异常,Java语言所有的异常都可以用一个类来表示,不同类型的异常对应不同的子类异常,每个异常都对应一个异常类的对象。Java异常处理通过5个关键字try、catch、finally、throw、thr...
    99+
    2023-05-30
    java exception 子类
  • Python自定义元类的实例讲解
    1、说明 一个类没有声明自己的元类,默认他的元类就是type,除了使用元类type,用户也可以通过继承type来自定义元类。 2、实例 我们可以使用类属性 __metaclass__...
    99+
    2024-04-02
  • Android手势操作简单实例讲解
    上一篇介绍的onTouch提供的事件还是相对较简单,如果需要处理一些复杂的手势,用这个接口就会很麻烦,因为我们要根据用户触摸的轨迹去判断是什么手势。幸好Android SDK给...
    99+
    2022-06-06
    Android
  • Android 对话框 Dialog使用实例讲解
    对话框 Dialog 什么是对话框 对话框是在当前的页面之上弹出的小窗口, 用于显示一些重要的提示信息, 提示用户的输入,确认信息,或显示某种状态.如 : 显示进度条对话框, ...
    99+
    2022-06-06
    dialog Android
  • 实例讲解Android中SQLiteDatabase使用方法
    SQLite数据库是android系统内嵌的数据库,小巧强大,能够满足大多数SQL语句的处理工作,而SQLite数据库仅仅是个文件而已。虽然SQLite的有点很多,但并不是如同...
    99+
    2022-06-06
    方法 Android
  • Android自定义控件LinearLayout实例讲解
    很多时候Android常用的控件不能满足我们的需求,那么我们就需要自定义一个控件了。今天做了一个自定义控件的实例,来分享下。 首先定义一个layout实现按钮内部布局:&nbs...
    99+
    2022-06-06
    Android
  • Android计时器chronometer使用实例讲解
    在Android中,可以使用计时器来实现对时间的监测,这个类所实现的功能有开始计时,停止计时,重新计时,设置计 时模式,下面列出计时器方法的原型: long getBase()...
    99+
    2022-06-06
    Android
  • Android判断用户的网络类型实例讲解(2/3/4G、wifi)
    很多时候需要先判断当前用户的网络,才会继续之后的一些处理逻辑。但网络类型获取这一块,我用我自己的的手机调试时遇到一些问题,这里记录一下。 一加手机一代,移动4G 网络,得到的...
    99+
    2022-06-06
    4g 网络类型 Android
  • php的Snoopy类案例讲解
    php的Snoopy类 获取请求网页里面的所有链接,直接使用fetchlinks就可以,获取所有文本信息使用fetchtext(其内部还是使用正则表达式在进行处理),还有其它较多的功...
    99+
    2024-04-02
  • php中日期类型转换实例讲解
    1、使用date()函数将UNIX时间戳转换为日期。 2、使用strtotime()函数将日期转换为UNIX时间戳。 在PHP中是可以完成日期格式转换的,不过有一个缺点就是占用PHP...
    99+
    2024-04-02
  • Java中类加载机制的实例讲解
    这篇文章主要介绍“Java中类加载机制的实例讲解”,在日常操作中,相信很多人在Java中类加载机制的实例讲解问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Java中类加载机制的实例讲解”的疑惑有所帮助!接下来...
    99+
    2023-06-20
  • 通过Class类获取对象(实例讲解)
    通过Class对象获取对象的方式是通过class.newInstance()方式获取,通过调用默认构造参数实例化一个对象。@Datapublic class Person { private String name; private i...
    99+
    2023-05-31
    class类 获取 对象
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作