安卓官方最新的API里为何只能找到Intent类,却找不到android.intent.*包?

安卓官方最新的API里(链接http://developer.android.com/reference/packages.html)为何只能找到Intent类,却找不到android.intent.*包?可在AndroidManifest.xml里面总是有:




这样的过滤语句。
这里面的intent从何而来,而Intent类是在android.content下的,这之间到底有何关联及区别?
注意:intent包i是小写,Intent类I是大写!

1个回答

Intent 类 是属于 android.Content包 下的

 import android.content.Intent;

而manifest中的intent:

比如:

 <category android:name="android.intent.category.LAUNCHER" />

只是一个常量而已:

  @SdkConstant(SdkConstantType.INTENT_CATEGORY)
    public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
如何调用android通讯录?

我正在写一个android应用程序,需要调用手机的通讯录。我需要调用通讯录的功能,选择一个联系人,然后将联系人的名字返回到我的应用程序中。下边是我在网上找的代码,但是不起作用。 import android.app.ListActivity; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.provider.Contacts.People; import android.view.View; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import android.widget.TextView; public class Contacts extends ListActivity { private ListAdapter mAdapter; public TextView pbContact; public static String PBCONTACT; public static final int ACTIVITY_EDIT=1; private static final int ACTIVITY_CREATE=0; // 当activity第一次创建完成后调用 @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Cursor C = getContentResolver().query(People.CONTENT_URI, null, null, null, null); startManagingCursor(C); String[] columns = new String[] {People.NAME}; int[] names = new int[] {R.id.row_entry}; mAdapter = new SimpleCursorAdapter(this, R.layout.mycontacts, C, columns, names); setListAdapter(mAdapter); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Cursor C = (Cursor) mAdapter.getItem(position); PBCONTACT = C.getString(C.getColumnIndex(People.NAME)); Intent i = new Intent(this, NoteEdit.class); startActivityForResult(i, ACTIVITY_CREATE); } }

修改Framework中API文件 出现cannot find symbol错误

frameworks中Intent中添加了 @SdkConstant(SdkConstantType.INTENT_CATEGORY) public static final String CATEGORY_HOME_UNIQUE = "android.intent.category.HOME_UNIQUE"; make clean;make update-api后为什么还是提示 frameworks/base/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java:126: cannot find symbol symbol : variable CATEGORY_HOME_UNIQUE location: class android.content.Intent homeIntent.addCategory(Intent.CATEGORY_HOME_UNIQUE); ^ 1 error frameworks/base/api/current.txt文件中已经添加进去了 field public static final java.lang.String CATEGORY_HOME_UNIQUE = "android.intent.category.HOME_UNIQUE"; 该如何解决呢?

Android百度地图API onReceiveLocation

onReceiveLocation 在模拟器上运行可以触发 移动到真机上onReceiveLocation触发不了 不知道为什么 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.baidumapdingwei" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <!-- service --> <service android:name="com.baidu.location.f" android:enabled="true" android:process=":remote"> </service> <!-- meta-data需要写在application中 --> <meta-data android:name="com.baidu.lbsapi.API_KEY" android:value="66iOAPAecwuaafXjw2XgaAGf" /> <activity android:name="com.example.baidumapdingwei.MainActivity" android:label="@string/app_name" > <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_COARSE_LOCATION" > </uses-permission> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" > </uses-permission> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" > </uses-permission> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" > </uses-permission> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" > </uses-permission> <uses-permission android:name="android.permission.READ_PHONE_STATE" > </uses-permission> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" > </uses-permission> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" > </uses-permission> <uses-permission android:name="android.permission.READ_LOGS" > </uses-permission> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> </manifest> java public class MainActivity extends Activity { private LocationClient mLocationClient; private TextView LocationResult; private Button startLocation; private BDLocation location1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mLocationClient = new LocationClient(getApplicationContext()); mLocationClient.registerLocationListener(new MyLocationListener()); LocationResult = (TextView)findViewById(R.id.textView1); startLocation = (Button)findViewById(R.id.button1); //startLocation.setOnClickListener(new OnClickListener() { } public void onClick(View v) { // TODO Auto-generated method stub InitLocation(); if(startLocation.getText().equals("start")){ mLocationClient.start(); //mLocationClient.requestLocation(); startLocation.setText("stop"); }else{ mLocationClient.stop(); startLocation.setText("start"); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override protected void onStop() { // TODO Auto-generated method stub mLocationClient.stop(); super.onStop(); } private void InitLocation(){ LocationClientOption option = new LocationClientOption(); //location1 = new LocationClient(getApplicationContext()); option.setLocationMode(LocationMode.Hight_Accuracy);//设置定位模式 option.setCoorType("gcj02");//返回的定位结果是百度经纬度,默认值gcj02 option.setScanSpan(5000);//设置发起定位请求的间隔时间为100ms option.setIsNeedAddress(true); option.setOpenGps(true); mLocationClient.setLocOption(option); } /** * 实现实位回调监听 */ public class MyLocationListener implements BDLocationListener { @Override public void onReceiveLocation(BDLocation location) { //Receive Location location1=location; StringBuffer sb = new StringBuffer(256); sb.append("time : "); sb.append(location.getTime()); sb.append("error code : "); sb.append(location.getLocType()); sb.append("latitude : "); sb.append(location.getLatitude()); sb.append("lontitude : "); sb.append(location.getLongitude()); sb.append("radius : "); sb.append(location.getRadius()); if (location.getLocType() == BDLocation.TypeGpsLocation){ sb.append("speed : "); sb.append(location.getSpeed()); sb.append("satellite : "); sb.append(location.getSatelliteNumber()); sb.append("direction : "); sb.append("addr : "); sb.append(location.getAddrStr()); sb.append(location.getDirection()); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation){ sb.append("addr : "); sb.append(location.getAddrStr()); //运营商信息 sb.append("operationers : "); sb.append(location.getOperators()); } int flag=location.getLocType(); String a="error : "; a=a+flag; sb.append(a); Toast.makeText(MainActivity.this, "sb", Toast.LENGTH_SHORT); Log.i("dwtedx", sb.toString()); } } } 布局 里面只有一个显示的TextView 定位的Button

在写一个AndroidBLE程序时,遇到了搜索不到设备的原因,怎么解决?

代码如下: 1.MainActivity部分 ``` public class MainActivity extends AppCompatActivity implements View.OnClickListener { private BluetoothAdapter mBluetoothAdapter; private RecyclerView mRecyclerView; private ScanResultAdapter mScanResultAdapter; private BluetoothLeScanner mBluetoothLeScanner; private Button mStartScaleButton,mStopScaleButton; private static final int REQUEST_CODE_ACCESS_COARSE_LOCATION = 1; //动态申请权限 private static final int SCAN_START = 1000; //开始搜索 private static final int SCAN_TIME = 10 * 1000; //扫描时间 private static final String TAG = "BLE"; private List<ScanResult> mList = new ArrayList<>(); private List<String> mListAddress = new ArrayList<>(); private Handler mHandler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(@NonNull Message msg) { switch (msg.what){ case SCAN_START: scanBluetooth(false); } return false; } }); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); SetOnClickListener(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {//如果 API level 是大于等于 23(Android 6.0) 时 //判断是否具有权限 if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { //判断是否需要向用户解释为什么需要申请该权限 if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_COARSE_LOCATION)) { Toast.makeText(MainActivity.this, "自Android 6.0开始需要打开位置权限才可以搜索到Ble设备", Toast.LENGTH_LONG).show(); } //请求权限 ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_CODE_ACCESS_COARSE_LOCATION); } } } private void initView(){ /*找到控件*/ mStartScaleButton = findViewById(R.id.bt_1); mStopScaleButton = findViewById(R.id.bt_2); mRecyclerView = findViewById(R.id.rv_1); mRecyclerView.addItemDecoration(new DividerItemDecoration(this,DividerItemDecoration.VERTICAL)); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); mScanResultAdapter = new ScanResultAdapter(this,mList); mRecyclerView.setAdapter(mScanResultAdapter); mScanResultAdapter.setOnItemClickListener(new ScanResultAdapter.OnItemClickListener() { @Override public void OnClick(int position) { scanBluetooth(false); ScanResult scanResult = mList.get(position); } }); /*获取本地蓝牙适配器*/ BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner(); if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, "设备不支持BLE", Toast.LENGTH_SHORT).show(); finish(); } /*打开蓝牙*/ if(mBluetoothAdapter == null ||!mBluetoothAdapter.isEnabled()){ Intent TrunOnBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(TrunOnBtIntent,0); } } /*控件点击事件*/ private void SetOnClickListener(){ mStartScaleButton.setOnClickListener(this); mStopScaleButton.setOnClickListener(this); } /*对应控件执行相关操作*/ @Override public void onClick(View v){ switch (v.getId()){ case R.id.bt_1: scanBluetooth(true); Toast.makeText(MainActivity.this,"扫描",Toast.LENGTH_LONG).show(); break; case R.id.bt_2: scanBluetooth(false); break; } } /*开始搜索设备及停止搜索设备函数*/ private void scanBluetooth(boolean isSan){ if(isSan==true){ mBluetoothLeScanner.startScan(mScanCallback); mHandler.sendEmptyMessageDelayed(SCAN_START,SCAN_TIME);//定时搜索蓝牙设备 }else { mBluetoothLeScanner.stopScan(mScanCallback); if(mHandler.hasMessages(SCAN_START)){ mHandler.removeMessages(SCAN_START); } } } /*搜索的回调函数*/ private ScanCallback mScanCallback = new ScanCallback() { @Override public void onScanResult(int callbackType, ScanResult result) { Log.i(TAG,"result:" + result + "callbackType:" + callbackType); /*通过扫描到的设备地址与新扫描的地址作比较,避免重复*/ if(!mListAddress.contains(result.getDevice().getAddress())){ mList.add(result); mListAddress.add(result.getDevice().getAddress()); } super.onScanResult(callbackType, result); } @Override /*扫描失败的处理*/ public void onScanFailed(int errorCode){ Log.e(TAG,"onScanFailed:" + errorCode); } }; } ``` 2. ScanResultAdapter部分 ``` public class ScanResultAdapter extends RecyclerView.Adapter<ScanResultAdapter.ViewHolder> { private Context mContext; private List<ScanResult> mList; private LayoutInflater inflater; private OnItemClickListener onItemClickListener; public ScanResultAdapter(Context mContext,List<ScanResult>mList){ this.mContext = mContext; this.mList = mList; inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public void setOnItemClickListener(OnItemClickListener onItemClickListener){ this.onItemClickListener = onItemClickListener; } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return new ViewHolder(inflater.from(mContext).inflate(R.layout.layout_scanadapter_item,parent,false)); } @Override public void onBindViewHolder(@NonNull ViewHolder holder, final int position) { ScanResult scanResult = mList.get(position); holder.tv_name.setText("设备名:"+scanResult.getDevice().getName()); holder.tv_address.setText("设备地址:"+scanResult.getDevice().getAddress()); holder.tv_rssi.setText("信号:"+scanResult.getRssi()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(null != onItemClickListener){ onItemClickListener.OnClick(position); } } }); } @Override public int getItemCount() { return mList.size(); } public class ViewHolder extends RecyclerView.ViewHolder{ private TextView tv_name; private TextView tv_address; private TextView tv_rssi; public ViewHolder(@NonNull View itemView) { super(itemView); tv_name = itemView.findViewById(R.id.tv_name); tv_address = itemView.findViewById(R.id.tv_address); tv_rssi = itemView.findViewById(R.id.tv_rssi); } } public interface OnItemClickListener{ void OnClick(int position); } } ```

android studio中AndroidManifest出错

Manifest。xml源码如下: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.administrator.myapplication" > <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <!-- The ACCESS_COARSE/FINE_LOCATION permissions are not required to use Google Maps Android API v2, but are recommended. --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.administrator.myapplication.MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MainActivity2Activity" android:label="MainActivity2Activity" > </activity> 下面略过五六个activity,都是同样的报错。 Android name那里error报的是"class"or"interface"expected 尝试过全称,可是依然是如上报错的。 想过重新创建项目再来一遍,可是打开软件就报错。。。QAQ 求各位大神,这是什么错误,该怎么解决呢?【最开始是因为一个改变了一个activity成了class,选择删除了那个activity注册的代码,结果。。。就出了以上的错误

Android 微信分享成功后没有回调

public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler,OnClickListener { private IWXAPI wx_api; ImageView share_friend; ImageView share_circle; TextView cancel; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fenxiang); share_friend = (ImageView) findViewById(R.id.share_friend); share_circle = (ImageView) findViewById(R.id.share_circle); cancel = (TextView) findViewById(R.id.quxiao); share_friend.setOnClickListener(this); share_circle.setOnClickListener(this); cancel.setOnClickListener(this); regToWx(); } public void cancel(View view) { finish(); } private void regToWx() { wx_api = WXAPIFactory.createWXAPI(this, "wx39f190a482377e7a"); wx_api.registerApp("wx39f190a482377e7a"); //wx_api.handleIntent(getIntent(), this); } @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent); wx_api.handleIntent(intent, this); } public void weiChatShareFriend() { if (!wx_api.isWXAppInstalled()) { Toast.makeText(WXPayEntryActivity.this, "您还未安装微信客户端", Toast.LENGTH_SHORT).show(); return; } WXWebpageObject webpage = new WXWebpageObject(); webpage.webpageUrl = "http://tv.csu.edu.cn/index.php?s=/Home/Article/detail/id/1857.html"; WXMediaMessage msg = new WXMediaMessage(webpage); msg.title = "来自XX的分享"; msg.description = "分享 XXadAndroid版"; SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = String.valueOf(System.currentTimeMillis()); req.message = msg; req.scene = SendMessageToWX.Req.WXSceneSession; wx_api.sendReq(req); } public void weiChatShareCricle(){ if (!wx_api.isWXAppInstalled()) { Toast.makeText(WXPayEntryActivity.this, "您还未安装微信客户端", Toast.LENGTH_SHORT).show(); return; } WXWebpageObject webpage = new WXWebpageObject(); webpage.webpageUrl = "http://baidu.com"; WXMediaMessage msg = new WXMediaMessage(webpage); msg.title = "来自XX的分享"; msg.description = "分享 XXadAndroid版"; SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = String.valueOf(System.currentTimeMillis()); req.message = msg; req.scene = SendMessageToWX.Req.WXSceneTimeline; wx_api.sendReq(req); } @Override public void onClick(View arg0) { switch (arg0.getId()) { case R.id.share_friend: weiChatShareFriend(); break; case R.id.share_circle: weiChatShareCricle(); break; case R.id.quxiao: finish(); break; default: break; } } @Override public void onReq(BaseReq arg0) { } @Override public void onResp(BaseResp resp) { String result = ""; switch (resp.errCode) { case BaseResp.ErrCode.ERR_OK: result = "errcode_success"; break; case BaseResp.ErrCode.ERR_USER_CANCEL: result = "errcode_cancel"; break; case BaseResp.ErrCode.ERR_AUTH_DENIED: result = "errcode_deny"; break; default: result = "errcode_unknown"; break; } Toast.makeText(this, result, Toast.LENGTH_LONG).show(); } 回调机制已经写上去了,但分享成功后没有出现“分享成功”的回调提示

耳机按键事件中音量加减这两个按键事件的怎么获取?

网上找的demo是在manifest里设置接收下面两个Action,并把优先级设为最高 ``` <action android:name="android.intent.action.MEDIA_BUTTON"/> <action android:name="android.media.AUDIO_BECOMING_NOISY" /> ``` 然后重写BroadcastReceiver的onReceive函数,获取Intent.Action_Media_Button的事件: ``` public void onReceive(Context context, Intent intent) { if(Intent.ACTION_MEDIA_BUTTON.equals(intentAction)){ KeyEvent keyEvent = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); //获得KeyEvent对象 int keyCode = keyEvent.getKeyCode(); Log.i(TAG,keyCode+""); } } ``` 但经过测试只能得到keycode-headsethook这个按键,也就是播放键的按键事件。按播放键可以输出对应的keycode。音量加与音量减的事件都接收不到,触发的还是系统的调整音量。 有没有大神做过这方面的app呢,麻烦给个demo参考一下,或者告知一下这方面的api要怎么找。 官方文档里我去找了一下,Intent.ACTION_MEDIA_BUTTON的说明是Broadcast Action: The "Media Button" was pressed。不清楚是只针对播放键的还是三个按键都包括。 唔,忘了C币一般是悬赏多少了,先放10个吧,能解决的话会追加的,谢谢各位大神。

高德地图能获取到经纬度,但不能将地图移动到定位点,

package com.example.zengyue.gould_map; import android.app.Activity; import android.content.Intent; import android.icu.text.SimpleDateFormat; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.util.Log; import android.view.Window; import android.widget.Toast; import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClientOption; import com.amap.api.location.AMapLocationListener; import com.amap.api.maps2d.AMap; import com.amap.api.maps2d.CameraUpdateFactory; import com.amap.api.maps2d.LocationSource; import com.amap.api.maps2d.MapView; import com.amap.api.maps2d.UiSettings; import com.amap.api.maps2d.model.LatLng; import java.util.Date; public class MainActivity extends Activity implements LocationSource,AMapLocationListener{ //AMap是地图对象 private AMap aMap; private MapView mMapView; //声明AMapLocationClient类对象,定位发起端 private AMapLocationClient mLocationClient = null; //声明mLocationOption对象,定位参数 public AMapLocationClientOption mLocationOption = null; //声明mListener对象,定位监听器 private OnLocationChangedListener mListener = null; //标识,用于判断是否只显示一次定位信息和用户重新定位 private boolean isFirstLoc = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); //获取地图控件 mMapView= (MapView) findViewById(R.id.map); //创建地图 mMapView.onCreate(savedInstanceState);//重写 if (aMap==null){ aMap =mMapView.getMap(); //设置显示定位按钮 并且可以点击 UiSettings settings = aMap.getUiSettings(); aMap.setLocationSource(this);//设置了定位的监听 // 是否显示定位按钮 settings.setMyLocationButtonEnabled(true); aMap.setMyLocationEnabled(true);//显示定位层并且可以触发定位,默认是flase } //开始定位 location(); } private void location() { //初始化定位 mLocationClient = new AMapLocationClient(getApplicationContext()); //初始化定位参数 mLocationOption = new AMapLocationClientOption(); //设置是否返回地址信息(默认返回地址信息) mLocationOption.setNeedAddress(true); //设置定位模式为Hight_Accuracy高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式 mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); // //设置是否只定位一次,默认为false // mLocationOption.setOnceLocation(false); // //设置是否强制刷新WIFI,默认为强制刷新 // mLocationOption.setWifiActiveScan(true); // //设置是否允许模拟位置,默认为false,不允许模拟位置 // mLocationOption.setMockEnable(true); //设置定位间隔,单位毫秒,默认为2000ms mLocationOption.setInterval(2000); //给定位客户端对象设置定位参数 mLocationClient.setLocationOption(mLocationOption); //启动定位 mLocationClient.startLocation(); //设置定位回调监听 mLocationClient.setLocationListener(this); } @Override protected void onResume() { super.onResume(); //重新绘制加载地图 mMapView.onResume(); } @Override protected void onPause() { super.onPause(); //暂停地图的绘制 mMapView.onResume(); } @Override protected void onDestroy() { super.onDestroy(); //销毁地图 mMapView.onDestroy(); mLocationClient.stopLocation();//停止定位 mLocationClient.onDestroy();//销毁定位客户端。 } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); //保存地图的当前状态 mMapView.onSaveInstanceState(outState); } @RequiresApi(api = Build.VERSION_CODES.N) @Override public void onLocationChanged(AMapLocation aMapLocation) { Log.i("ttt",">>>>>>>>>>1"); if (aMapLocation != null) { Log.i("ttt",">>>>>>>>>>2"); if (aMapLocation.getErrorCode() == 0) { Log.i("ttt",">>>>>>>>>>"+aMapLocation.getLatitude()+">>>>>>>>>"+//获取纬度 aMapLocation.getLongitude()); //定位成功回调信息,设置相关消息 aMapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见官方定位类型表 aMapLocation.getLatitude();//获取纬度 aMapLocation.getLongitude();//获取经度 aMapLocation.getAccuracy();//获取精度信息 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(aMapLocation.getTime()); df.format(date);//定位时间 aMapLocation.getAddress();//地址,如果option中设置isNeedAddress为false,则没有此结果,网络定位结果中会有地址信息,GPS定位不返回地址信息。 aMapLocation.getCountry();//国家信息 aMapLocation.getProvince();//省信息 aMapLocation.getCity();//城市信息 aMapLocation.getDistrict();//城区信息 aMapLocation.getStreet();//街道信息 aMapLocation.getStreetNum();//街道门牌号信息 aMapLocation.getCityCode();//城市编码 aMapLocation.getAdCode();//地区编码 Log.i("ttt",aMapLocation.getCountry().toString()+aMapLocation.getProvince().toString()+aMapLocation.getCity().toString()+aMapLocation.getDistrict().toString()+aMapLocation.getStreet().toString()); // 如果不设置标志位,此时再拖动地图时,它会不断将地图移动到当前的位置 if (isFirstLoc) { //设置缩放级别 aMap.moveCamera(CameraUpdateFactory.zoomTo(17)); //将地图移动到定位点 aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude()))); //点击定位按钮 能够将地图的中心移动到定位点 mListener.onLocationChanged(aMapLocation); //添加图钉 // aMap.addMarker(getMarkerOptions(amapLocation)); //获取定位信息 StringBuffer buffer = new StringBuffer(); buffer.append(aMapLocation.getCountry() + "" + aMapLocation.getProvince() + "" + aMapLocation.getCity() + "" + aMapLocation.getProvince() + "" + aMapLocation.getDistrict() + "" + aMapLocation.getStreet() + "" + aMapLocation.getStreetNum()); Toast.makeText(getApplicationContext(), buffer.toString(), Toast.LENGTH_LONG).show(); isFirstLoc = false; Log.i("ttt",buffer.toString()); } } else { //显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。 Log.e("AmapError", "location Error, ErrCode:" + aMapLocation.getErrorCode() + ", errInfo:" + aMapLocation.getErrorInfo()); Toast.makeText(getApplicationContext(), "定位失败", Toast.LENGTH_LONG).show(); } } } //激活定位 @Override public void activate(OnLocationChangedListener onLocationChangedListener) { mListener=onLocationChangedListener; } //停止定位 @Override public void deactivate() { mListener=null; } } ``` <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.zengyue.gould_map"> <!--用于进行网络定位--> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission> <!--用于访问GPS定位--> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission> <!--用于获取运营商信息,用于支持提供运营商信息相关的接口--> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> <!--用于访问wifi网络信息,wifi信息会用于进行网络定位--> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> <!--用于获取wifi的获取权限,wifi信息会用来进行网络定位--> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission> <!--用于访问网络,网络定位需要上网--> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <!--用于读取手机当前的状态--> <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> <!--用于写入缓存数据到扩展存储卡--> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> <!--用于申请调用A-GPS模块--> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission> <!--用于申请获取蓝牙信息进行室内定位--> <uses-permission android:name="android.permission.BLUETOOTH"></uses-permission> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <service android:name="com.amap.api.location.APSService"/> <meta-data android:name="com.amap.api.v2.apikey" android:value="c0fede08d244f741d053af1396317383" /> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> ``` <?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" tools:context="com.example.zengyue.gould_map.MainActivity"> <com.amap.api.maps2d.MapView android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent"> </com.amap.api.maps2d.MapView> </RelativeLayout>

openmobileAPI如何保证与手机版本相符?

org.simalliance.openmobileapi 21版本 之前未升级的手机上可以使用 手机升级到Android9后 不好使了 报SEService: bindingSuccessful: false public SEService(Context context, SEService.CallBack listener) { if(context == null) { throw new NullPointerException("context must not be null"); } else { this.mContext = context; this.mCallerCallback = listener; this.mConnection = new ServiceConnection() { public synchronized void onServiceConnected(ComponentName className, IBinder service) { SEService.this.mSmartcardService = org.simalliance.openmobileapi.service.ISmartcardService.Stub.asInterface(service); if(SEService.this.mCallerCallback != null) { SEService.this.mCallerCallback.serviceConnected(SEService.this); } Log.v("SEService", "Service onServiceConnected"); } public void onServiceDisconnected(ComponentName className) { SEService.this.mSmartcardService = null; Log.v("SEService", "Service onServiceDisconnected"); } }; Intent intent = new Intent("org.simalliance.openmobileapi.BIND_SERVICE"); intent.setPackage("org.simalliance.openmobileapi.service"); boolean bindingSuccessful = this.mContext.bindService(intent, this.mConnection, 1); Log.v("SEService", "bindingSuccessful: " + bindingSuccessful); } }

如何检查一个服务是否在 Android 上运行?

<div class="post-text" itemprop="text"> <p>How do I check if a background service (on Android) is running?</p> <p>I want an Android activity that toggles the state of the service -- it lets me turn it on if it is off and off if it is on.</p> </div> <p>转载于:https://stackoverflow.com/questions/600207/how-to-check-if-a-service-is-running-on-android</p>

调用外部API不成功,显示的什么执行时间长,我实在解决不了了

下面是我的util package textview.exam; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; /** * Created by fei on 2016/6/16. */ public class Shishinews { String httpUrl = "http://apis.baidu.com/songshuxiansheng/news/news"; String httpArg = ""; String jsonResult = request(httpUrl, httpArg); //System.out.println(jsonResult); /** * @param urlAll * :请求接口 * @param httpArg * :参数 * @return 返回结果 */ public static String request(String httpUrl, String httpArg) { BufferedReader reader = null; String result = null; StringBuffer sbf = new StringBuffer(); httpUrl = httpUrl + "?" + httpArg; try { URL url = new URL(httpUrl); HttpURLConnection connection = (HttpURLConnection) url .openConnection(); connection.setRequestMethod("GET"); // 填入apikey到HTTP header connection.setRequestProperty("apikey", "f761aa7e1d7b5ebe4******"); connection.connect(); InputStream is = connection.getInputStream(); reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String strRead = null; while ((strRead = reader.readLine()) != null) { sbf.append(strRead); sbf.append("\r\n"); } reader.close(); result = sbf.toString(); } catch (Exception e) { e.printStackTrace(); } return result; } } 下面是我fragment的代码 package textview.exam; import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.Toast; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class FragmentMainchatnews extends Fragment { String httpUrl = "http://apis.baidu.com/songshuxiansheng/news/news"; String httpArg = ""; private String[] title;//新闻标题 private String[] abs;//新闻简介 private String[] image_url;//图片链接地址 Thread thread = null; String newsjson; @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // TODO Auto-generated method stub View view=inflater.inflate(R.layout.main_chat_news, null); return view; } // 开启线程得到答案 Runnable runnable = new Runnable() { @Override public void run() { newsjson = Shishinews.request(httpUrl, httpArg); Log.v("debug",newsjson); Message message = new Message(); message.what = 1;// 标志是哪个线程传数据 } }; @SuppressLint("HandlerLeak") class MyHandler extends Handler { // 接受message的信息 @Override public void handleMessage(Message msg) { super.handleMessage(msg); try { JSONObject object = new JSONObject(newsjson); newsjson = object.get("retDate").toString(); } catch (JSONException e) { e.printStackTrace(); } if (msg.what == 1) { // 创建一个List集合,List集合的元素是Map List<Map<String, Object>> listItems = new ArrayList<Map<String, Object>>(); for (int i = 0; i < title.length; i++) { Map<String, Object> listItem = new HashMap<String, Object>(); listItem.put("image", image_url[i]); listItem.put("title", title[i]); listItem.put("abs", abs[i]); listItems.add(listItem); } // 创建一个SimpleAdapter SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), listItems,R.layout.simple_item, new String[]{"image", "title", "abs"}, new int[]{R.id.image, R.id.title ,R.id.abs}); ListView list = (ListView) getView().findViewById(R.id.chat_news); // 为ListView设置Adapter list.setAdapter(simpleAdapter); // 为ListView的列表项的单击事件绑定事件监听器 list.setOnItemClickListener(new AdapterView.OnItemClickListener() { // 第position项被单击时激发该方法 @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent=new Intent(getActivity(),ChatActivity.class); startActivity(intent); } }); // 为ListView的列表项的选中事件绑定事件监听器 list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { // 第position项被选中时激发该方法 @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { System.out.println(title[position] + "被选中了"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } } } public void sendMessage() { if (getView().findViewById(R.id.chat_news)==null) { Toast.makeText(getActivity(), "下拉刷新", Toast.LENGTH_SHORT).show(); } else { // 创建一个List集合,List集合的元素是Map List<Map<String, Object>> listItems = new ArrayList<Map<String, Object>>(); for (int i = 0; i < title.length; i++) { Map<String, Object> listItem = new HashMap<String, Object>(); listItem.put("image", image_url[i]); listItem.put("title", title[i]); listItem.put("abs", abs[i]); listItems.add(listItem); } thread = new Thread(runnable); thread.start(); } } } 下面是我AndroidMainfest.xml中的代码 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="textview.exam" > <!-- 添加权限 --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.USE_CREDENTIALS" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".LoginActivity" android:label="@string/title_activity_login" android:windowSoftInputMode="adjustResize|stateHidden" > </activity> <activity android:name=".ChatActivity" android:label="@string/title_activity_chat" > android:labl="聊天" </activity> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> </application> </manifest> 该有的权限我应该都设置了,可是还是不成功,大神们啊,这个我是解决不了了,就想获取个简单的新闻,我连什么关键词都没有

android微信分享成功不回调

``` package com.xcy.wxtest.wxapi; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import com.tencent.mm.sdk.constants.ConstantsAPI; import com.tencent.mm.sdk.modelbase.BaseReq; import com.tencent.mm.sdk.modelbase.BaseResp; import com.tencent.mm.sdk.modelmsg.SendAuth; import com.tencent.mm.sdk.modelmsg.SendMessageToWX; import com.tencent.mm.sdk.modelmsg.WXMediaMessage; import com.tencent.mm.sdk.modelmsg.WXTextObject; import com.tencent.mm.sdk.openapi.IWXAPI; import com.tencent.mm.sdk.openapi.IWXAPIEventHandler; import com.tencent.mm.sdk.openapi.WXAPIFactory; import com.xcy.wxtest.R; public class WXEntryActivity extends Activity implements IWXAPIEventHandler{ private EditText editText; private Button button; private Button btn_open_wx; private IWXAPI apis; private static final String APP_ID = "wx8368d8d70626b02e"; private static final String App_Secret = "a212499f83a99516b45f1fb9c5686e9a"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); } private void initView() { apis = WXAPIFactory.createWXAPI(this, APP_ID, false); editText = (EditText)findViewById(R.id.editText); button = (Button)findViewById(R.id.button); btn_open_wx = (Button)findViewById(R.id.btn_open_wx); addListeners(); } private void addListeners() { System.out.println("=========listener============="); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String text = editText.getText().toString(); if(text == null || text.length() == 0 ){ Toast.makeText(WXEntryActivity.this, "输入内同不为空", Toast.LENGTH_SHORT).show(); } WXTextObject textobj = new WXTextObject(); textobj.text = text; WXMediaMessage msg = new WXMediaMessage(); msg.mediaObject = textobj; msg.description = text; SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = buildTraction("text"); req.message = msg; req.scene = req.WXSceneTimeline;//WXSceneTimeline 朋友圈 ,Session 表示发送到会话 apis.sendReq(req); } }); btn_open_wx.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(WXEntryActivity.this, "launch result:" + apis.openWXApp(), Toast.LENGTH_SHORT ).show(); } }); } @Override public void onReq(BaseReq req) { System.out.println("=========onReq============="); } // @Override // public void onResp(BaseResp resp) { // System.out.println("=========onResp============="); // if(resp.getType() == ConstantsAPI.COMMAND_SENDAUTH){ // Toast.makeText(WXEntryActivity.this, "code = "+((SendAuth.Resp) resp).errCode, Toast.LENGTH_SHORT).show(); // } // switch(resp.errCode){ // case BaseResp.ErrCode.ERR_OK: // Toast.makeText(WXEntryActivity.this, "分享成功!", Toast.LENGTH_SHORT); // break; // case BaseResp.ErrCode.ERR_AUTH_DENIED: // Toast.makeText(WXEntryActivity.this, "分享被拒绝!", Toast.LENGTH_SHORT); // break; // // } // } @Override public void onResp(BaseResp resp) { Toast.makeText(this, "openid = " + resp.openId, Toast.LENGTH_SHORT).show(); System.out.println("================onResp================="); if (resp.getType() == ConstantsAPI.COMMAND_SENDAUTH) { Toast.makeText(this, "code = " + ((SendAuth.Resp) resp).code, Toast.LENGTH_SHORT).show(); } String result = ""; switch (resp.errCode) { case BaseResp.ErrCode.ERR_OK: result = "成功"; break; case BaseResp.ErrCode.ERR_USER_CANCEL: result = "取消"; break; case BaseResp.ErrCode.ERR_AUTH_DENIED: result = "拒绝"; break; default: result = "。。。。"; break; } Toast.makeText(this, result, Toast.LENGTH_LONG).show(); } private String buildTraction(final String type){ return (type == null) ? String.valueOf(System.currentTimeMillis()) : type + System.currentTimeMillis(); } } ```

Android 微信支付成功不走回调问题

如题,搞了好久,还是没找到问题,APP支付成功了,点击返回商家,然后没走回调,但是log显示: 进入微信支付的log 03-28 15:02:16.671 1067-1651/? W/InterceptionReason: reason:6)finally, intercept as usual, interception = false details<<runType:activity isFgAction:true callerPkg:com.hc.house calleePkg:com.tencent.mm processName:com.tencent.mm Intent { flg=0x10000 cmp=com.tencent.mm/.plugin.base.stub.WXPayEntryActivity (has extras) }>> 03-28 15:02:16.672 1067-1651/? I/ActivityManager: START u0 {flg=0x10000 cmp=com.tencent.mm/.plugin.base.stub.WXPayEntryActivity (has extras)} from uid 10187 on display 0 最后出现一条LOG 03-28 15:17:37.042 30014-30014/? W/MicroMsg.SDK.WXApiImplV10: context is not instanceof Activity or Service, disable WXStat 不太懂什么意思 这里是支付完成后的log 03-28 15:02:38.763 1067-1131/? W/InterceptionReason: reason:6)finally, intercept as usual, interception = false details<<runType:activity isFgAction:true callerPkg:com.tencent.mm calleePkg:com.hc.house processName:com.hc.house Intent { flg=0x10000000 cmp=com.hc.house/.wxapi.WXPayEntryActivity (has extras) }>> 03-28 15:02:38.764 1067-1131/? I/ActivityManager: START u0 {flg=0x10000000 cmp=com.hc.house/.wxapi.WXPayEntryActivity (has extras)} from uid 10113 on display 0 但是就是没进入WXPayEntryActivity,奇怪的是取消支付就正常走业务了, 配置: <!-- wxpay --> <activity android:name=".wxapi.WXPayEntryActivity" android:exported="true" android:launchMode="singleTop" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar" /> 项目结构: ![图片说明](https://img-ask.csdn.net/upload/201803/28/1522221210_904171.png) WXPayEntryActivity: /支付成功回调页 public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler { private IWXAPI api; static int payType=-1;//标识 public static Handler Typehandler=new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); payType=msg.what; //获取支付类型 Log.e("微信支付 ","当前获取类型 "+payType); } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); api = WXAPIFactory.createWXAPI(WXPayEntryActivity.this,HmApplication.WXAPPID); api.handleIntent(getIntent(), WXPayEntryActivity.this); } @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent); api.handleIntent(intent,WXPayEntryActivity.this); } @Override public void onReq(BaseReq baseReq) { Log.e("微信支付 ","进入支付回调页onReq "+payType); } @Override public void onResp(BaseResp baseResp) { Log.e("微信支付 ","进入支付回调页onResp "+payType +" 支付完成code "+baseResp.errCode); if (baseResp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) { if(baseResp.errCode==-1){ setPayResult("支付失败"); } if(baseResp.errCode==0){ setPayResult("支付完成"); } if(baseResp.errCode==-2){ setPayResult("取消支付"); } } } private void setPayResult(String msg){ HmToast.show(WXPayEntryActivity.this,msg,300); finish(); } @Override protected void onDestroy() { super.onDestroy(); } }

调用百度API做了个身份证信息查询APP,询问程序不能正常运行原因

``` package com.jingyou.id; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class MainActivity extends AppCompatActivity implements View.OnClickListener{ private String sex; private String birthday; private String address; private TextView result; private EditText editText; private Button button; private String httpUrl; private String httpArg; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); editText= (EditText) findViewById(R.id.edit); result= (TextView) findViewById(R.id.result); button= (Button) findViewById(R.id.button); httpUrl = "http://apis.baidu.com/apistore/idservice/id"; httpArg = editText.getText().toString(); //httpArg = "61052619910128001X"; button.setOnClickListener(this); } @Override public void onClick(View v) { if(v.getId()==R.id.button){ request(httpUrl, httpArg); } } private Handler handler=new Handler(){ public void handleMessage(Message msg){ switch(msg.what){ case 0: String r= (String) msg.obj; try{ JSONObject jsonObject=new JSONObject(r); JSONObject weatherInfo=jsonObject.getJSONObject("retData"); sex=weatherInfo.getString("sex"); birthday=weatherInfo.getString("birthday"); address=weatherInfo.getString("address"); }catch (JSONException e){ e.printStackTrace(); } result.setText(" "+sex+" "+birthday+" "+address+" "+httpArg); } } }; private void request(final String httpUrl, final String httpArg) { new Thread(new Runnable() { @Override public void run() { HttpURLConnection connection=null; try { URL url = new URL(httpUrl + "?id=" + httpArg); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setConnectTimeout(8000); connection.setReadTimeout(8000); // 填入apikey到HTTP header connection.setRequestProperty("apikey", "9683743a3bd1ba305d7874f6bc7b5bcf"); connection.connect(); InputStream is = connection.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String strRead; StringBuilder sbf=new StringBuilder(); while ((strRead = reader.readLine()) != null) { sbf.append(strRead); } Message message=new Message(); message.what=0; message.obj=sbf.toString(); handler.sendMessage(message); } catch (Exception e) { e.printStackTrace(); }finally { if(connection!=null){ connection.disconnect(); } } } }).start(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } ``` ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:text="请输入身份证号:" android:gravity="center_horizontal" android:textSize="30sp"/> <EditText android:id="@+id/edit" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="30dp" android:background="#fff"/> <TextView android:id="@+id/result" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="30dp" android:layout_gravity="center_horizontal" android:text="查询"/> </LinearLayout> ``` ``` <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jingyou.id" > <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> ``` 代码如上,理想情况下输入完身份证号后按下查询按钮,就会在TextView中显示内容,可实际显示null null null 程序也不是很复杂,实在找不出问题所在,求大神指点

Android开发:魅蓝note3跳转通讯录读取联系人信息失败

魅蓝note3(手机Android5.1 API 22),跳转通讯录页面,获取联系人,返回结果没有查询到。(其他华为,小米,三星机型都可) Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0

android 开发中界面的跳转

我想设置一个监听器直接跳到android模拟器自带的无线和网络设置(Wireless&networks)界面,请大神帮个忙

Android模拟器连接到http://10.0.2.2拒绝

<div class="post-text" itemprop="text"> <p>I got this error on an Android Emulator when I tried connecting to a local server:</p> <pre><code>I/System.out﹕ org.apache.http.conn.HttpHostConnectException: Connection to http://10.0.2.2 refused </code></pre> <p>This is the code that I used to connect to the local server (<a href="http://10.0.2.2/bank/login.php" rel="nofollow noreferrer">http://10.0.2.2/bank/login.php</a>):</p> <pre class="lang-java prettyprint-override"><code>HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://10.0.2.2/bank/login.php"); //HttpPost httppost = new HttpPost("http://10.0.2.2:80/bank/login.php"); //HttpPost httppost = new HttpPost("http://10.0.2.2:8080/bank/login.php"); try { List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2); nameValuePairs.add(new BasicNameValuePair("username", "Will")); nameValuePairs.add(new BasicNameValuePair("password", "password")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); } catch (IOException e) { // TODO Auto-generated catch block System.out.println("API LOGIN"); System.out.println(e); } </code></pre> <p>Also, I've added <code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;</code> to the AndroidManifest.xml file. The content of my AndroidManifest.xml is:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.dev.will.test" &gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name=".MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".LoginActivity" android:label="Login" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>There is no problem with the local server, since I can access to the url <a href="http://10.0.2.2/bank/login.php" rel="nofollow noreferrer">http://10.0.2.2/bank/login.php</a> from the browser of the Android Emulator without problem and also from another computer within network, but the connection is refused from my Android application.</p> <p>Please help me to figure out what can else I should configure to make it work on my app in the Android Emulator.</p> </div>

关于高德地图绘制区域面的问题?有大神解答一下吗?

我的代码是这样的 ``` package com.chenxi.bimquanziguankong.activity; import android.Manifest; import android.content.Context; import android.content.Intent; import android.graphics.BitmapFactory; import android.graphics.Color; import android.os.Bundle; import android.support.annotation.NonNull; import android.text.method.ScrollingMovementMethod; import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClientOption; import com.amap.api.maps2d.AMap; import com.amap.api.maps2d.CameraUpdateFactory; import com.amap.api.maps2d.LocationSource; import com.amap.api.maps2d.MapView; import com.amap.api.maps2d.UiSettings; import com.amap.api.maps2d.model.BitmapDescriptorFactory; import com.amap.api.maps2d.model.LatLng; import com.amap.api.maps2d.model.Marker; import com.amap.api.maps2d.model.MarkerOptions; import com.amap.api.maps2d.model.MyLocationStyle; import com.amap.api.maps2d.model.PolygonOptions; import com.blankj.utilcode.util.ToastUtils; import com.chenxi.bimquanziguankong.R; import com.chenxi.bimquanziguankong.entity.ProjectInfo; import com.chenxi.bimquanziguankong.utils.LocationUtil; import java.util.ArrayList; import java.util.List; import pub.devrel.easypermissions.EasyPermissions; public class ProjectSurveyActivity extends BaseActivity implements LocationSource, EasyPermissions.PermissionCallbacks { private Context context; private ProjectInfo projectInfo;//从ProjectChooseActivity传过来的ProjectInfo private AMapLocationClient aMapLocationClient; private AMapLocationClientOption clientOption; private TextView projectSurvey; private ImageView back; private MapView mapView; private AMap aMap; private LocationSource.OnLocationChangedListener mListener = null;//定位监听器 private LocationUtil locationUtil; private String[] jiweiData; private double mlat, mlgt; private String Coordinate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_project_survey); //获取从ProjectChooseActivity传递过来的数据 Intent intent = getIntent(); projectInfo = (ProjectInfo) intent.getSerializableExtra("projectInfo"); Coordinate = projectInfo.getCoordinate(); Log.e("TAG", "噢噢噢噢 " + Coordinate); projectSurvey = findViewById(R.id.tv_project_survey); if (projectInfo.getDescription() != null) { projectSurvey.setText(projectInfo.getDescription());//概况描述 } projectSurvey.setMovementMethod(ScrollingMovementMethod.getInstance());//把TextView设置成可滑动 projectSurvey = findViewById(R.id.tv_project_survey); back = findViewById(R.id.toolbar_left_btn); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); mapView = findViewById(R.id.project_survey_map); // 必须要写 mapView.onCreate(savedInstanceState); // 开启定位权限,并开始定位 if (EasyPermissions.hasPermissions(this, Manifest.permission.ACCESS_COARSE_LOCATION)) {//检查是否获取该权限 init(); } else { //第二个参数是被拒绝后再次申请该权限的解释 //第三个参数是请求码 //第四个参数是要申请的权限 EasyPermissions.requestPermissions(this, "定位需要定位权限", 0, Manifest.permission.ACCESS_COARSE_LOCATION); } } private void init() { if (aMap == null) { aMap = mapView.getMap(); } setLocationCallBack(); //设置定位监听 aMap.setLocationSource(this); //设置缩放级别 aMap.moveCamera(CameraUpdateFactory.zoomTo(17)); // 设置显示定位按钮 并且可以点击 UiSettings settings = aMap.getUiSettings(); // 是否显示定位按钮 settings.setMyLocationButtonEnabled(false); // 关闭一切手势操作 settings.setAllGesturesEnabled(true); // 是否显示缩放按钮 settings.setZoomControlsEnabled(false); MyLocationStyle myLocationStyle = new MyLocationStyle(); myLocationStyle.myLocationIcon(BitmapDescriptorFactory .fromResource(R.drawable.maplocation));// 设置小蓝点的图标 myLocationStyle.strokeColor(Color.argb(0, 0, 0, 0));// 设置圆形的边框颜色 myLocationStyle.radiusFillColor(Color.argb(0, 0, 0, 0));// 设置圆形的填充颜色 myLocationStyle.strokeWidth(0f);// 设置圆形的边框粗细 // myLocationStyle.anchor(int,int)//设置小蓝点的锚点 // getMap().setLatLonQuanVisible(false); aMap.getUiSettings().setCompassEnabled(false); aMap.setMyLocationStyle(myLocationStyle); aMap.getUiSettings().setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示 // aMap.setMyLocationType() //显示定位层并可触发,默认false aMap.setMyLocationEnabled(true); aMap.setMapType(AMap.MAP_TYPE_SATELLITE); // LatLng latLng = new LatLng(38.906901,116.397972); // final Marker marker = aMap.addMarker(new MarkerOptions().position(latLng).title("").snippet("DefaultMarker")); } private void setLocationCallBack() { if (Coordinate != null) { jiweiData = Coordinate.substring(2, Coordinate.length() - 2).split(","); Log.e("TAG", " qqqqqqqq" + jiweiData); mlgt = Double.parseDouble(jiweiData[0].substring(1)); mlat = Double.parseDouble(jiweiData[1].substring(0, jiweiData[1].length() - 1)); Log.e("TAG", " wwwww" + mlgt + "rrrrrrr" + mlat); LatLng latLng1=new LatLng(108.286888,22.8389); LatLng latLng2=new LatLng(108.284566,22.8354); LatLng latLng3=new LatLng(108.287462,22.838598); LatLng latLng4=new LatLng(108.287215,22.83846); LatLng latLng5=new LatLng(108.286952,22.838504); /* LatLng latLng1 = new LatLng(Double.parseDouble(jiweiData[0].substring(1)) , Double.parseDouble(jiweiData[1].substring(0, jiweiData[1].length() - 1))); LatLng latLng2 = new LatLng(Double.parseDouble(jiweiData[2].substring(1)), Double.parseDouble(jiweiData[3].substring(0, jiweiData[3].length() - 1))); LatLng latLng3 = new LatLng(Double.parseDouble(jiweiData[4].substring(1)) , Double.parseDouble(jiweiData[5].substring(0, jiweiData[5].length() - 1))); LatLng latLng4 = new LatLng(Double.parseDouble(jiweiData[6].substring(1)) , Double.parseDouble(jiweiData[7].substring(0, jiweiData[7].length() - 1))); LatLng latLng5 = new LatLng(Double.parseDouble(jiweiData[8].substring(1)), Double.parseDouble(jiweiData[9].substring(0, jiweiData[9].length() - 1)));*/ // LatLng latLng2=new LatLng(Double.parseDouble(jiweiData[2].substring(1)),Double.parseDouble(jiweiData[3].substring(0, jiweiData[1].length() - 1))); //根据获取的经纬度,将地图移动到定位位置 aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(mlat, mlgt))); MarkerOptions markerOptions = new MarkerOptions(); markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.maplocation)); markerOptions.position(new LatLng(mlat, mlgt)); markerOptions.title("位置"); markerOptions.snippet("纬度:" + mlat + " 经度:" + mlgt); markerOptions.period(100); aMap.addMarker(markerOptions); // List<LatLng> latLngs = new ArrayList<>(); //latLngs.add(1,Double.parseDouble(jiweiData[0].substring(1))); /// latLngs.add(new LatLng(Double.parseDouble(jiweiData[2].substring(1)), //Double.parseDouble(jiweiData[3].substring(0, jiweiData[3].length() - 1)))); /* latLngs.add(new LatLng(Double.parseDouble(jiweiData[2].substring(1)), Double.parseDouble(jiweiData[3].substring(0, jiweiData[3].length() - 1)))); latLngs.add(new LatLng(Double.parseDouble(jiweiData[3].substring(1)), Double.parseDouble(jiweiData[4].substring(0, jiweiData[4].length() - 1)))); latLngs.add(new LatLng(Double.parseDouble(jiweiData[4].substring(1)), Double.parseDouble(jiweiData[5].substring(0, jiweiData[5].length() - 1))));*/ Log.e("TAG", "经纬度456 " + latLng1 + "a" + latLng2 + latLng3 + latLng4 + latLng5); PolygonOptions polygonOptions = new PolygonOptions(); polygonOptions.add(latLng1, latLng2, latLng3, latLng4, latLng5); polygonOptions.strokeWidth(15) .strokeColor(Color.argb(50, 1, 1, 1)) .fillColor(Color.argb(1, 1, 1, 1)); aMap.addPolygon(polygonOptions); Log.e("TAG", "运行到这里啦: "); /* mListener.onLocationChanged(aMapLocation); //添加定位图标 aMap.addMarker(locationUtil.getMarkerOption(str, mlat, mlgt));*/ } /*locationUtil = new LocationUtil(); locationUtil.setLocationCallBack(new LocationUtil.ILocationCallBack() { @Override public void callBack(String str, double lat, double lgt, AMapLocation aMapLocation) { // if(Coordinate==null){ // //根据获取的经纬度,将地图移动到定位位置 // aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(lat, lgt))); // mListener.onLocationChanged(aMapLocation); // //添加定位图标 // aMap.addMarker(locationUtil.getMarkerOption(str, lat, lgt)); // }else } }); */ } //定位激活回调 @Override public void activate(OnLocationChangedListener onLocationChangedListener) { mListener = onLocationChangedListener; locationUtil.startLocate(getApplicationContext()); } @Override public void deactivate() { mListener = null; } @Override protected void onPause() { super.onPause(); //暂停地图的绘制 mapView.onPause(); } @Override protected void onDestroy() { super.onDestroy(); //销毁地图 mapView.onDestroy(); } @Override protected void onResume() { super.onResume(); //重新绘制加载地图 mapView.onResume(); } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState); } // @Override // public void onPermissionsGranted(int i, List<String> list) { // // } // // @Override // public void onPermissionsDenied(int i, List<String> list) { // // } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); //把申请权限的回调交由EasyPermissions处理 EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this); } //下面两个方法是实现EasyPermissions的EasyPermissions.PermissionCallbacks接口 //分别返回授权成功和失败的权限 @Override public void onPermissionsGranted(int requestCode, List<String> perms) { if (perms.get(0).equals("android.permission.READ_PHONE_STATE")) { ToastUtils.showShort("READ_PHONE_STATE权限获取成功"); } else if (perms.get(0).equals("android.permission.ACCESS_COARSE_LOCATION")) { ToastUtils.showShort("定位权限获取成功"); init(); } } @Override public void onPermissionsDenied(int requestCode, List<String> perms) { if (perms.get(0).equals("android.permission.ACCESS_COARSE_LOCATION")) { ToastUtils.showShort("定位权限获取失败,请在设置中手动开启"); } } } ``` 我的log打印出来的数据是 ``` 07-16 17:38:51.294 19116-19116/com.chenxi.bimquanziguankong E/TAG: 噢噢噢噢 [[[108.286888,22.8389],[108.287317,22.8389],[108.287462,22.838598],[108.287215,22.83846],[108.286952,22.838504]]] 07-16 17:38:51.426 19116-19116/com.chenxi.bimquanziguankong E/TAG: qqqqqqqq[Ljava.lang.String;@282045c3 07-16 17:38:51.426 19116-19116/com.chenxi.bimquanziguankong E/TAG: wwwww108.286888rrrrrrr22.8389 07-16 17:38:51.439 19116-19116/com.chenxi.bimquanziguankong E/TAG: 经纬度456 lat/lng: (90.0,22.8389)alat/lng: (90.0,22.8389)lat/lng: (90.0,22.838598)lat/lng: (90.0,22.83846)lat/lng: (90.0,22.838504) 07-16 17:38:51.449 19116-19116/com.chenxi.bimquanziguankong E/TAG: 运行到这里啦: ``` 就是它的经度会变成90.0无论我给它的经度是多少都是90.然后区域也画不出来。有大神知道什么原因吗?

Android的ListView读取不了图片

注 :我是用Android Studio开发的,我是从网络获取图片数据的,在线等: 以下是代码: package com.example.ai.helloworld; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import com.loopj.android.http.AsyncHttpClient; import com.loopj.android.http.JsonHttpResponseHandler; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.LinkedList; import java.util.List; import cn.trinea.android.common.service.impl.ImageCache; import cz.msebera.android.httpclient.Header; public class ListViewActivity extends BaseActivity { //获取网络数据绑定 @Override public String getTag() { return "ListView"; } //初始化数据 public void init(){ AsyncHttpClient client = new AsyncHttpClient(); client.get("http://www.showfm.net/api/novel.asp",new JsonHttpResponseHandler(){ @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { // If the response is JSONObject instead of expected JSONArray //输出获取的数据 Log.d(ListViewActivity.this.getTag(),response.toString()); try { JSONObject jsnobject = new JSONObject(String.valueOf(response)); JSONArray jsonarray = jsnobject.getJSONArray("novels"); for(int i = 0;i<jsonarray.length();++i){ JSONObject jnovel = jsonarray.getJSONObject(i); ItemObj itemobj = new ItemObj(jnovel.getInt("id"),jnovel.getString("nj_name"),jnovel.getString("nj_avatar")); datas.add(itemobj); } myAdapter.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onSuccess(int statusCode, Header[] headers, JSONArray timeline) { // Pull out the first event on the public timeline } }); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list_view); listView = (ListView)findViewById(R.id.listview); myAdapter = new MyAdapter(); listView.setAdapter(myAdapter); imageCache = new ImageCache(); init(); myAdapter.notifyDataSetChanged(); } class MyAdapter extends BaseAdapter{ @Override public int getCount(){ return datas.size(); } @Override public Object getItem(int position){ return datas.get(position); } @Override public long getItemId(int position){ return 0; } @Override public View getView(int position, View convertView, ViewGroup parent){ Holder holder; if(convertView == null){ convertView = getLayoutInflater().inflate(R.layout.listview_item,null); holder = new Holder(); holder.name = (TextView) convertView.findViewById(R.id.ls_tx); convertView.setTag(holder); }else{ holder = (Holder) convertView.getTag(); } ItemObj item = (ItemObj)getItem(position); imageCache.get(item.avatar,holder.img); holder.name.setText(item.nj_name); return convertView; } class Holder { ImageView img; TextView name; } } class ItemObj{ public ItemObj(int novel_id,String name,String avatar) { this.novel_id = novel_id; this.nj_name = name; this.avatar = avatar; } public int novel_id; public String nj_name; public String avatar; } ListView listView; List<ItemObj> datas = new LinkedList<>(); MyAdapter myAdapter; ImageCache imageCache; } 提示的错误: 09-09 08:44:46.590 2622-3046/com.example.ai.helloworld E/ImageSDCardCache: get image exception while write to file, imageUrl is: http://www.showfm.net/api/avatar/Jummy.jpg, savePath is /storage/emulated/0/Trinea/AndroidCommon/ImageCache/http___www_showfm_net_api_avatar_Jummy_jpg java.lang.RuntimeException: FileNotFoundException occurred. at cn.trinea.android.common.util.FileUtils.writeFile(FileUtils.java:247) at cn.trinea.android.common.util.FileUtils.writeFile(FileUtils.java:210) at cn.trinea.android.common.util.FileUtils.writeFile(FileUtils.java:197) at cn.trinea.android.common.service.impl.ImageSDCardCache$3.onGetData(ImageSDCardCache.java:833) at cn.trinea.android.common.service.impl.ImageSDCardCache$3.onGetData(ImageSDCardCache.java:809) at cn.trinea.android.common.service.impl.PreloadDataCache$GetDataThread.run(PreloadDataCache.java:569) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) Caused by: java.io.FileNotFoundException: /storage/emulated/0/Trinea/AndroidCommon/ImageCache/http___www_showfm_net_api_avatar_Jummy_jpg (No such file or directory) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.<init>(FileOutputStream.java:221) at cn.trinea.android.common.util.FileUtils.writeFile(FileUtils.java:238) at cn.trinea.android.common.util.FileUtils.writeFile(FileUtils.java:210)  at cn.trinea.android.common.util.FileUtils.writeFile(FileUtils.java:197)  at cn.trinea.android.common.service.impl.ImageSDCardCache$3.onGetData(ImageSDCardCache.java:833)  at cn.trinea.android.common.service.impl.ImageSDCardCache$3.onGetData(ImageSDCardCache.java:809)  at cn.trinea.android.common.service.impl.PreloadDataCache$GetDataThread.run(PreloadDataCache.java:569)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)  at java.lang.Thread.run(Thread.java:761)  效果图片: ![图片说明](https://img-ask.csdn.net/upload/201709/09/1504947224_828714.png)

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

你以为这样写Java代码很6,但我看不懂

为了提高 Java 编程的技艺,我最近在 GitHub 上学习一些高手编写的代码。下面这一行代码(出自大牛之手)据说可以征服你的朋友,让他们觉得你写的代码很 6,来欣赏一下吧。 IntStream.range(1, 5).boxed().map(i -&gt; { System.out.print("Happy Birthday "); if (i == 3) return "dear NAME"...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

立即提问
相关内容推荐