我有一些数据(5 行和一张图像)所有这些都需要发送到服务器。此外,这些行之一必须包含上传(到服务器)的图像的地址。如何组织所有这些业务?首先 POST 图片,然后使用 GET 获取它的地址并将其插入到一个字符串中,然后对这些字符串进行 POST 请求,还是有更正确的方法吗?所有这些都将在 Android 上使用 Retrofit
Infernal's questions
我有一个带有 MVVM 和 Dagger 的应用程序。当我打开应用程序并加载列表时,我会在日志中看到服务器如何不断地请求列表。可能是什么问题呢?我的网络模块:
@Module(includes = [ViewModelModule::class])
class NetworkModule {
companion object {
const val KEY = "key"
const val BASE_URL = "base_url"
}
@Provides
@Singleton
fun provideOkHttp(): OkHttpClient {
val httpClient = OkHttpClient.Builder()
httpClient.addInterceptor(object : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): okhttp3.Response {
val original = chain.request()
val originalHttpUrl = original.url
val url = originalHttpUrl.newBuilder()
//.addQueryParameter("apikey", KEY)
.build()
val requestBuilder = original.newBuilder()
.url(url)
.header("apikey", KEY)
val request = requestBuilder.build()
return chain.proceed(request)
}
})
// logging interceptor
val logging = HttpLoggingInterceptor()
logging.level = HttpLoggingInterceptor.Level.BODY
httpClient.addInterceptor(logging)
return httpClient.build()
}
@Provides
@Singleton
fun provideRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.client(provideOkHttp())
.build()
}
@Provides
@Singleton
fun provideContactsService(retrofit: Retrofit) : ContactsService{
return retrofit.create(ContactsService::class.java)
}
}
视图模型:
class ContactsViewModel @Inject constructor(private val contactsRepository: ContactsRepository) :
ViewModel() {
var mutableLiveData = MutableLiveData<List<ContactsModel>>()
private val disposable = CompositeDisposable()
fun getContactMutableLiveData(): MutableLiveData<List<ContactsModel>> {
loadData()
return mutableLiveData
}
fun loadData() {
disposable.add(contactsRepository.modelSingle()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(object : DisposableSingleObserver<List<ContactsModel>>() {
override fun onSuccess(t: List<ContactsModel>) {
getContactMutableLiveData().value = t
}
override fun onError(e: Throwable) {
}
})
)
}
}
订阅接收数据的活动部分:
contactsViewModel.getContactMutableLiveData().observe(this@ContactListActivity, Observer {
mAdapter = ContactsAdapter(this@ContactListActivity, it as ArrayList<ContactsModel>)
recycler_contacts.layoutManager =
LinearLayoutManager(applicationContext, OrientationHelper.VERTICAL, false)
recycler_contacts.adapter = mAdapter
recycler_contacts.setHasFixedSize(true)
mAdapter.sortByName()
})
有一个开关按钮 SwitchCompat,当它被启用时,应该会来一个本地通知。问题是如果你设置了时间,然后打开拨动开关,那么通知就会来,但是如果你让拨动开关打开并设置一个新的通知时间,直到你关闭并打开它才会来再次在拨动开关上。如何解决?据我了解,该程序只检查一次拨动开关是否打开?
活动代码片段:
public class AlarmActivity extends AppCompatActivity implements TimePickerDialog.OnTimeSetListener {
private EditText mondayText;
private SwitchCompat mondaySwitch;
SharedPreferences sPref;
String timeText = "";
final String SAVED_TEXT = "saved_text";
boolean switch_On_Off;
public static final String PREFS_NAME = "Switch_On_Off_check";
final Calendar c = Calendar.getInstance();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarm);
mondayText = findViewById(R.id.monday_time);
mondaySwitch = findViewById(R.id.switch_monday);
// load SharedPref save text in mondayText and save switch On else Off
loadText();
loadSwitchCheck();
mondaySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
startAlarm(c);
saveSwitchCheck();
}
});
mondayText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogFragment timePicker = new TimePickerFragment();
timePicker.show(getSupportFragmentManager(), "time picker");
}
});
}
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
c.set(Calendar.HOUR_OF_DAY, hourOfDay);
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
updateTimeText(c);
}
private void updateTimeText(Calendar c) {
// clean EditText time
timeText = "";
timeText += DateFormat.getTimeInstance(DateFormat.SHORT).format(c.getTime());
mondayText.setText(timeText);
saveText();
}
public void startAlarm(Calendar c) {
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(this, AlertReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1, intent, 0);
if (c.before(Calendar.getInstance())) {
c.add(Calendar.DATE, 1);
}
alarmManager.setExact(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pendingIntent);
}
所以,我做了一个检查来打开/关闭开关(或者我想我做了),但现在通知总是来,布尔 OnOff 变量被完全忽略
更正的代码:
public class AlarmActivity extends AppCompatActivity implements TimePickerDialog.OnTimeSetListener {
private EditText mondayText;
public SwitchCompat mondaySwitch;
SharedPreferences sPref;
String timeText = "";
final String SAVED_TEXT = "saved_text";
boolean switch_On_Off;
boolean OnOff;
public static final String PREFS_NAME = "Switch_On_Off_check";
final Calendar c = Calendar.getInstance();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarm);
mondayText = findViewById(R.id.monday_time);
mondaySwitch = findViewById(R.id.switch_monday);
// load SharedPref save text in mondayText and save switch On else Off
loadText();
loadSwitchCheck();
mondaySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (mondaySwitch.isChecked()) {
OnOff = true;
Toast.makeText(getApplicationContext(), "Включено", Toast.LENGTH_SHORT).show();
} else {
OnOff = false;
Toast.makeText(getApplicationContext(), "Выключено", Toast.LENGTH_SHORT).show();
}
saveSwitchCheck();
}
});
mondayText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogFragment timePicker = new TimePickerFragment();
timePicker.show(getSupportFragmentManager(), "time picker");
}
});
}
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
c.set(Calendar.HOUR_OF_DAY, hourOfDay);
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
updateTimeText(c);
if (OnOff = true) {
startAlarm(c);
} else {
Toast.makeText(getApplicationContext(), "Включите", Toast.LENGTH_SHORT).show();
}
}
private void updateTimeText(Calendar c) {
timeText = "";
timeText += DateFormat.getTimeInstance(DateFormat.SHORT).format(c.getTime());
mondayText.setText(timeText);
saveText();
}
public void startAlarm(Calendar c) {
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(this, AlertReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1, intent, 0);
if (c.before(Calendar.getInstance())) {
c.add(Calendar.DATE, 1);
}
alarmManager.setExact(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pendingIntent);
}
有一款适用于 android 的游戏,通过 Google Play Services 设置了排行榜,对我来说一切正常,它显示了积分记录,它还显示了其他用户。但是有些用户,当他们点击排行榜按钮时,它(表格)打开并立即关闭。什么可以是门框?从哪个方向看,控制台或游戏中没有错误。不知道能不能在这里发个游戏链接供大家测试。
Buildbox中有一个“编写”的项目并导入Android Studio。在工作室本身中,使用按钮创建了一个 Activity,单击时会打开另一个 Activity,其中加载了游戏资源并打开了一个菜单。当调用 onBackPressed 方法时,应用程序只是简单地关闭而不是返回到之前的 Activity,日志为空,一切都没有错误,但该方法不起作用。
第一个活动代码:
package com.companyname.gamename;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
public class MActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_m);
}
public void btnStart (View view) {
Intent intent = new Intent(MActivity.this, PTPlayer.class);
startActivity(intent);
finish();
}
}
第二个活动代码:
package com.companyname.gamename;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager;
import android.widget.Toast;
import com.secrethq.store.PTStoreBridge;
import com.google.android.gms.games.GamesActivityResultCodes;
import com.secrethq.ads.*;
import com.secrethq.utils.*;
public class PTPlayer extends Cocos2dxActivity {
private static native void loadModelController();
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
Log.v("----------","onActivityResult: request: " + requestCode + " result: "+ resultCode);
if(PTStoreBridge.iabHelper().handleActivityResult(requestCode, resultCode, data)){
Log.v("-----------", "handled by IABHelper");
}
else if(requestCode == PTServicesBridge.RC_SIGN_IN){
if(resultCode == RESULT_OK){
PTServicesBridge.instance().onActivityResult(requestCode, resultCode, data);
}
else if(resultCode == GamesActivityResultCodes.RESULT_SIGN_IN_FAILED){
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(this, "Google Play Services: Sign in error", duration);
toast.show();
}
else if(resultCode == GamesActivityResultCodes.RESULT_APP_MISCONFIGURED){
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(this, "Google Play Services: App misconfigured", duration);
toast.show();
}
}
} catch (Exception e) {
Log.v("-----------", "onActivityResult FAIL on iabHelper : " + e.toString());
}
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PTServicesBridge.initBridge(this, getString( R.string.app_id ));
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
@Override
public void onNativeInit(){
initBridges();
}
private void initBridges(){
PTStoreBridge.initBridge( this );
if (PTJniHelper.isAdNetworkActive("kChartboost")) {
PTAdChartboostBridge.initBridge(this);
}
if (PTJniHelper.isAdNetworkActive("kRevMob")) {
PTAdRevMobBridge.initBridge(this);
}
if (PTJniHelper.isAdNetworkActive("kAdMob") || PTJniHelper.isAdNetworkActive("kFacebook")) {
PTAdAdMobBridge.initBridge(this);
}
if (PTJniHelper.isAdNetworkActive("kAppLovin")) {
PTAdAppLovinBridge.initBridge(this);
}
if (PTJniHelper.isAdNetworkActive("kLeadBolt")) {
PTAdLeadBoltBridge.initBridge(this);
}
if (PTJniHelper.isAdNetworkActive("kFacebook")) {
PTAdFacebookBridge.initBridge(this);
}
if (PTJniHelper.isAdNetworkActive("kHeyzap")) {
PTAdHeyzapBridge.initBridge(this);
}
}
@Override
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
glSurfaceView.setEGLConfigChooser(8, 8, 8, 0, 0, 0);
return glSurfaceView;
}
static {
System.loadLibrary("player");
}
@Override
public void onBackPressed() {
//MemoryManager.onBackPressed();
//exitConfirmation(this);
Intent intent3 = new Intent(this, MActivity.class);
startActivity(intent3);
}
@Override
protected void onResume() {
super.onResume();
if (PTJniHelper.isAdNetworkActive("kChartboost")) {
PTAdChartboostBridge.onResume( this );
}
}
@Override
protected void onStart() {
super.onStart();
if (PTJniHelper.isAdNetworkActive("kChartboost")) {
PTAdChartboostBridge.onStart( this );
}
}
@Override
protected void onStop() {
super.onStop();
if (PTJniHelper.isAdNetworkActive("kChartboost")) {
PTAdChartboostBridge.onStop( this );
}
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}
日志:
2019-06-09 00:43:53.872 11254-11254/? I/zygote: Late-enabling -Xcheck:jni
2019-06-09 00:43:53.971 11254-11262/? E/zygote: Failed sending reply to debugger: Broken pipe
2019-06-09 00:43:53.972 11254-11262/? I/zygote: Debugger is no longer active
2019-06-09 00:43:54.111 11254-11254/? I/MultiDex: VM with version 2.1.0 has multidex support
2019-06-09 00:43:54.111 11254-11254/? I/MultiDex: Installing application
2019-06-09 00:43:54.111 11254-11254/? I/MultiDex: VM has multidex support, MultiDex support library is disabled.
2019-06-09 00:43:54.130 11254-11254/? I/FirebaseInitProvider: FirebaseApp initialization unsuccessful
2019-06-09 00:43:54.324 11254-11299/? D/OpenGLRenderer: HWUI GL Pipeline
2019-06-09 00:43:54.380 11254-11299/? I/Adreno: QUALCOMM build : d916c72, I7663a5f222
Build Date : 10/04/18
OpenGL ES Shader Compiler Version: EV031.22.00.01_06_07
Local Branch :
Remote Branch :
Remote Branch :
Reconstruct Branch :
2019-06-09 00:43:54.387 11254-11299/? I/Adreno: PFP: 0x005ff087, ME: 0x005ff063
2019-06-09 00:43:54.392 11254-11299/? I/com.companyname.gamename: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
2019-06-09 00:43:54.393 11254-11299/? I/OpenGLRenderer: Initialized EGL, version 1.4
2019-06-09 00:43:54.393 11254-11299/? D/OpenGLRenderer: Swap behavior 2
2019-06-09 00:43:58.923 11254-11254/com.companyname.gamename D/JniHelper: JniHelper::setJavaVM(0xef719140), pthread_self() = -216894300
2019-06-09 00:43:58.981 11254-11254/com.companyname.gamename D/Cocos2dxActivity: model=Redmi 4 Prime
2019-06-09 00:43:58.982 11254-11254/com.companyname.gamename D/Cocos2dxActivity: product=markw
2019-06-09 00:43:58.982 11254-11254/com.companyname.gamename D/Cocos2dxActivity: isEmulator=false
2019-06-09 00:43:59.017 11254-11254/com.companyname.gamename W/SoundPool: Use of stream types is deprecated for operations other than volume control
2019-06-09 00:43:59.017 11254-11254/com.companyname.gamename W/SoundPool: See the documentation of SoundPool() for what to use instead with android.media.AudioAttributes to qualify your playback use case
2019-06-09 00:43:59.018 11254-11254/com.companyname.gamename V/PTServicesBridge: PTServicesBridge -- INIT
2019-06-09 00:43:59.021 11254-11254/com.companyname.gamename D/PTPlayer: [PTPSettingsController] - loadInventoryMap
2019-06-09 00:43:59.083 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] -- Cleaning
2019-06-09 00:43:59.095 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelGeneralSettings.0.attributes.xml
2019-06-09 00:43:59.098 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelFont.0.attributes.xml
2019-06-09 00:43:59.099 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelScreen.0.attributes.xml
2019-06-09 00:43:59.101 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectLabel.0.attributes.xml
2019-06-09 00:43:59.141 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelScreen.0.connections.xml
2019-06-09 00:43:59.141 11254-11320/com.companyname.gamename D/PTPlayer: [PTPAppDelegate] game loading: start
2019-06-09 00:43:59.264 11254-11320/com.companyname.gamename D/PTPlayer: [PTPAppDelegate] device orientation: 1
2019-06-09 00:43:59.264 11254-11320/com.companyname.gamename D/PTPlayer: [PTPAppDelegate] screen adjustment: 0
2019-06-09 00:43:59.268 11254-11320/com.companyname.gamename D/PTPlayer: [PTPSettingsController] - loadInventoryMap
2019-06-09 00:43:59.270 11254-11320/com.companyname.gamename D/DeviceTypeRuntimeCheck: Running on a non-TV Device
2019-06-09 00:43:59.290 11254-11320/com.companyname.gamename D/PTPlayer: scale X: 1.690141 Y: 1.690141
2019-06-09 00:43:59.291 11254-11320/com.companyname.gamename D/PTPlayer: [PTPAppDelegate] loading time: 0.025731
2019-06-09 00:43:59.291 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] -- Cleaning
2019-06-09 00:43:59.296 11254-11320/com.companyname.gamename D/PTPlayer: [PTPScreenStart] banner: kNoAds interstitial: kNoAds
2019-06-09 00:43:59.431 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelGeneralSettings.0.attributes.xml
2019-06-09 00:43:59.528 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectEventObserver.0.attributes.xml
2019-06-09 00:43:59.577 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectButtonFacebook.0.attributes.xml
2019-06-09 00:43:59.611 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectImage.0.attributes.xml
2019-06-09 00:43:59.694 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectAssetUnit.0.attributes.xml
2019-06-09 00:43:59.829 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelComponentCharacterGameplaySettings.0.attributes.xml
2019-06-09 00:43:59.898 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectButtonControl.0.attributes.xml
2019-06-09 00:43:59.949 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectAssetParticles.0.attributes.xml
2019-06-09 00:44:00.032 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelComponentWakeup.0.attributes.xml
2019-06-09 00:44:00.098 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelAnimation.0.attributes.xml
2019-06-09 00:44:00.130 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelComponentDeletionThreshold.0.attributes.xml
2019-06-09 00:44:00.183 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectButtonSoundControl.0.attributes.xml
2019-06-09 00:44:00.232 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectAssetLight.0.attributes.xml
2019-06-09 00:44:00.283 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectBackground.0.attributes.xml
2019-06-09 00:44:00.315 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelFont.0.attributes.xml
2019-06-09 00:44:00.366 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelAtlas.0.attributes.xml
2019-06-09 00:44:00.415 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelSpriteContainer.0.attributes.xml
2019-06-09 00:44:00.464 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelScreenScene.0.attributes.xml
2019-06-09 00:44:00.515 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelLevelSection.0.attributes.xml
2019-06-09 00:44:00.549 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelScreen.0.attributes.xml
2019-06-09 00:44:00.582 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelLinker.0.attributes.xml
2019-06-09 00:44:00.631 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelSprite.0.attributes.xml
2019-06-09 00:44:00.731 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelAssetCharacter.0.attributes.xml
2019-06-09 00:44:00.766 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTNodeScene.0.attributes.xml
2019-06-09 00:44:00.799 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTNodeUI.0.attributes.xml
2019-06-09 00:44:00.849 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectButton.0.attributes.xml
2019-06-09 00:44:00.881 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTNodeUIStart.0.attributes.xml
2019-06-09 00:44:00.914 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelAssetObstacle.0.attributes.xml
2019-06-09 00:44:00.947 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelComponentHealth.0.attributes.xml
2019-06-09 00:44:00.982 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelAssetPowerup.0.attributes.xml
2019-06-09 00:44:01.031 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectAssetCharacter.0.attributes.xml
2019-06-09 00:44:01.082 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectLabel.0.attributes.xml
2019-06-09 00:44:01.148 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectAssetLogic.0.attributes.xml
2019-06-09 00:44:01.179 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectAssetParticlesEmitter.0.attributes.xml
2019-06-09 00:44:01.298 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectAssetPowerup.0.attributes.xml
2019-06-09 00:44:01.349 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(0) for class from file: data/PTModelObjectAssetScreenJump.0.attributes.xml
2019-06-09 00:44:01.398 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelGeneralSettings.0.connections.xml
2019-06-09 00:44:01.480 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectEventObserver.0.connections.xml
2019-06-09 00:44:01.530 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectButtonFacebook.0.connections.xml
2019-06-09 00:44:01.563 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectImage.0.connections.xml
2019-06-09 00:44:01.596 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectAssetUnit.0.connections.xml
2019-06-09 00:44:01.629 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelComponentCharacterGameplaySettings.0.connections.xml
2019-06-09 00:44:01.698 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectButtonControl.0.connections.xml
2019-06-09 00:44:01.748 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectAssetParticles.0.connections.xml
2019-06-09 00:44:01.832 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelComponentWakeup.0.connections.xml
2019-06-09 00:44:01.898 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelAnimation.0.connections.xml
2019-06-09 00:44:01.932 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelComponentDeletionThreshold.0.connections.xml
2019-06-09 00:44:01.981 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectButtonSoundControl.0.connections.xml
2019-06-09 00:44:02.032 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectAssetLight.0.connections.xml
2019-06-09 00:44:02.082 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectBackground.0.connections.xml
2019-06-09 00:44:02.115 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelFont.0.connections.xml
2019-06-09 00:44:02.165 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelAtlas.0.connections.xml
2019-06-09 00:44:02.215 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelSpriteContainer.0.connections.xml
2019-06-09 00:44:02.265 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelScreenScene.0.connections.xml
2019-06-09 00:44:02.315 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelLevelSection.0.connections.xml
2019-06-09 00:44:02.347 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelScreen.0.connections.xml
2019-06-09 00:44:02.380 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelLinker.0.connections.xml
2019-06-09 00:44:02.431 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelSprite.0.connections.xml
2019-06-09 00:44:02.532 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelAssetCharacter.0.connections.xml
2019-06-09 00:44:02.565 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTNodeScene.0.connections.xml
2019-06-09 00:44:02.598 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTNodeUI.0.connections.xml
2019-06-09 00:44:02.649 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectButton.0.connections.xml
2019-06-09 00:44:02.683 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTNodeUIStart.0.connections.xml
2019-06-09 00:44:02.716 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelAssetObstacle.0.connections.xml
2019-06-09 00:44:02.749 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelComponentHealth.0.connections.xml
2019-06-09 00:44:02.782 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelAssetPowerup.0.connections.xml
2019-06-09 00:44:02.831 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectAssetCharacter.0.connections.xml
2019-06-09 00:44:02.881 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectLabel.0.connections.xml
2019-06-09 00:44:02.915 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectAssetLogic.0.connections.xml
2019-06-09 00:44:02.948 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectAssetParticlesEmitter.0.connections.xml
2019-06-09 00:44:03.031 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectAssetPowerup.0.connections.xml
2019-06-09 00:44:03.081 11254-11320/com.companyname.gamename D/PTPlayer: [PTModelController] load data(1) for class from file: data/PTModelObjectAssetScreenJump.0.connections.xml
2019-06-09 00:44:03.117 11254-11320/com.companyname.gamename D/PTPlayer: End loading XML
2019-06-09 00:44:03.117 11254-11320/com.companyname.gamename D/PTPlayer: [PTPSettingsController] - loadInventoryMap
2019-06-09 00:44:03.117 11254-11320/com.companyname.gamename D/PTPlayer: [PTPSettingsController] - load
2019-06-09 00:44:03.149 11254-11320/com.companyname.gamename D/PTPlayer: invenotory count: 0
2019-06-09 00:44:03.150 11254-11320/com.companyname.gamename D/PTPlayer: characters count: 1
2019-06-09 00:44:03.150 11254-11320/com.companyname.gamename D/PTPlayer: load character: PTP_Character_0 = 0:1
2019-06-09 00:44:03.153 11254-11320/com.companyname.gamename D/PTPlayer: [PTPSettingsController] - load complete
2019-06-09 00:44:03.153 11254-11320/com.companyname.gamename D/PTPlayer: Init Android JNI Bridges
2019-06-09 00:44:03.169 11254-11320/com.companyname.gamename E/PTServicesBridge: PTServicesBridge -- loadingDidComplete
2019-06-09 00:44:03.169 11254-11320/com.companyname.gamename V/PTServicesBridge: PTServicesBridge -- Login Game Services
2019-06-09 00:44:03.169 11254-11320/com.companyname.gamename D/PTPlayer: [PTAdController] init Ad Networks
2019-06-09 00:44:03.169 11254-11320/com.companyname.gamename D/PTPlayer: Platform: Google Play
2019-06-09 00:44:03.170 11254-11320/com.companyname.gamename D/PTPlayer: Start Atlas loading
2019-06-09 00:44:03.170 11254-11320/com.companyname.gamename D/PTPlayer: loading atlas
2019-06-09 00:44:03.170 11254-11320/com.companyname.gamename D/PTPlayer: data/atlases/atlas_ID107.plist
2019-06-09 00:44:03.406 11254-11320/com.companyname.gamename D/PTPlayer: loading atlas
2019-06-09 00:44:03.407 11254-11320/com.companyname.gamename D/PTPlayer: data/atlases/atlas_ID2330.plist
2019-06-09 00:44:03.544 11254-11320/com.companyname.gamename D/PTPlayer: loading screens
2019-06-09 00:44:03.546 11254-11320/com.companyname.gamename D/DeviceTypeRuntimeCheck: Running on a non-TV Device
2019-06-09 00:44:03.548 11254-11320/com.companyname.gamename D/PTPlayer: [PTPScreenMainMenuUI] banner: kNoAds interstitial: kNoAds
2019-06-09 00:44:07.870 11254-11320/com.companyname.gamename D/PTPlayer: [PTPInputController] key Down clicked
2019-06-09 00:44:07.870 11254-11320/com.companyname.gamename V/PTPLAYER: KEY DOWN4
2019-06-09 00:44:07.903 11254-11320/com.companyname.gamename D/PTPlayer: [PTPInputController] key UP clicked
2019-06-09 00:44:07.903 11254-11320/com.companyname.gamename D/PTPlayer: key Back CLCIKED
2019-06-09 00:44:07.903 11254-11320/com.companyname.gamename D/PTPlayer: [PTPScreenUi] keyBackClicked
2019-06-09 00:44:07.903 11254-11320/com.companyname.gamename D/PTPlayer: [PTPSettingsController] - save
2019-06-09 00:44:07.935 11254-11320/com.companyname.gamename D/PTPlayer: [PTPSettingsController] - save complete
2019-06-09 00:44:07.936 11254-11320/com.companyname.gamename V/PTPLAYER: KEY UP4
2019-06-09 00:44:07.939 11254-11320/com.companyname.gamename I/Process: Sending signal. PID: 11254 SIG: 9
我正在尝试在 Fragment 中创建一个可扩展的 ListView,问题是,在所有指南中,组和列表名称的数组使用如下:
// названия компаний (групп)
String[] groups = new String[] {"HTC", "@Samsung", "@LG"};
// названия телефонов (элементов)
String[] phonesHTC = new String[] {"Sensation", "Desire", "Wildfire", "Hero"};
String[] phonesSams = new String[] {"Galaxy S II", "Galaxy Nexus", "Wave"};
String[] phonesLG = new String[] {"Optimus", "Optimus Link", "Optimus Black", "Optimus One"};
是否有将它们转移到字符串资源的选项,以便在将应用程序翻译成其他语言时,您不会遇到这个问题?试图在字符串资源中创建
<string-array name="1-10">
<item>Раз</item>
<item>Два</item>
<item>Три</item>
<item>Четыре</item>
<item>Пять</item>
<item>Шесть</item>
<item>Семь</item>
<item>Восемь</item>
<item>Девять</item>
<item>Десять</item>
</string-array>
但应用程序崩溃,发生错误,指出给定数组为空。
如果你继承自 android.app.ListFragment 那么应用程序在启动时崩溃,如何正确地将 ListView 注入 Fragment?片段代码:
public class Fragment_AAC extends android.app.ListFragment {
String[] base_AAC = getResources().getStringArray(R.array.base_AAC);
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public Fragment_AAC() {
// Required empty public constructor
}
public static Fragment_AAC newInstance(String param1, String param2) {
Fragment_AAC fragment = new Fragment_AAC();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ListAdapter adapter = new ArrayAdapter<>(getActivity(),
android.R.layout.simple_list_item_1, base_AAC);
setListAdapter(adapter);
标记:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.shark.sportplus.fragments.Fragment_AAC"
android:id="@+id/nav_aac">
<ListView
android:id="@+id/listView_aac"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</FrameLayout>
日志:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sharkitt.sportplus/com.sharkitt.sportplus.MainActivity}: java.lang.IllegalStateException: Fragment Fragment_AAC{9fe2943} not attached to Activity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2455)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2515)
at android.app.ActivityThread.access$1000(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1379)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5555)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
Caused by: java.lang.IllegalStateException: Fragment Fragment_AAC{9fe2943} not attached to Activity
at android.app.Fragment.getResources(Fragment.java:805)
at com.sharkitt.sportplus.fragments.Fragment_AAC.<init>(Fragment_AAC.java:22)
at com.sharkitt.sportplus.MainActivity.onCreate(MainActivity.java:66)
at android.app.Activity.performCreate(Activity.java:6357)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2408)
... 9 more
PS不建议从android.support.v4.app.ListFragment继承,因为FragmentTransaction会停止工作
有一个基础Acrivity,里面有Fragment_Go和Button go_button,怎么点击这个按钮去Fragment_Train呢?在代码中,我在 OnCreate 和 OnClick 中编写了以下几行,应用程序启动时没有错误,但按下按钮时没有任何反应。活动代码:
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
Fragment_Go fgo;
Fragment_Programs fprograms;
Fragment_Settings fsettings;
Fragment_Statistic fstatistic;
Fragment_Uprajnenia fuprajnenia;
Fragment_zameri fzameri;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
fgo = new Fragment_Go();
if (fgo != null) {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.container, fgo);
fragmentTransaction.commit();
}
fprograms = new Fragment_Programs();
fsettings = new Fragment_Settings();
fstatistic = new Fragment_Statistic();
fuprajnenia = new Fragment_Uprajnenia();
fzameri = new Fragment_zameri();
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
int id = item.getItemId();
FragmentTransaction ftrans = getFragmentManager().beginTransaction();
if (id == R.id.nav_go) {
ftrans.replace(R.id.container, fgo);
} else if (id == R.id.nav_programs) {
ftrans.replace(R.id.container, fprograms);
}else if (id == R.id.nav_uprajnenia) {
ftrans.replace(R.id.container, fuprajnenia);
}else if (id == R.id.nav_statistic) {
ftrans.replace(R.id.container, fstatistic);
} else if (id == R.id.nav_zameri) {
ftrans.replace(R.id.container, fzameri);
} else if (id == R.id.nav_settings) {
ftrans.replace(R.id.container, fsettings);
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}
ftrans.commit();
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}
第一个片段代码:
public class Fragment_Go extends Fragment implements View.OnClickListener {
Fragment_Train f_train;
@Override
public void onClick(View view) {
FragmentTransaction ftrans = getFragmentManager().beginTransaction();
if (getId() == R.id.go_button) {
ftrans.replace(R.id.container, f_train);
}
ftrans.commit();
}
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public Fragment_Go() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_Go.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_Go newInstance(String param1, String param2) {
Fragment_Go fragment = new Fragment_Go();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment__go, container, false);
Button go_button = (Button) rootView.findViewById(R.id.go_button);
go_button.setOnClickListener(this);
return rootView;
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
启动应用时,启动了一个空的Activity,如何从侧边菜单启动第一个Fragment?
活动代码:
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
Fragment_Go fgo;
Fragment_Programs fprograms;
Fragment_Settings fsettings;
Fragment_Statistic fstatistic;
Fragment_Uprajnenia fuprajnenia;
Fragment_zameri fzameri;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
fgo = new Fragment_Go();
fprograms = new Fragment_Programs();
fsettings = new Fragment_Settings();
fstatistic = new Fragment_Statistic();
fuprajnenia = new Fragment_Uprajnenia();
fzameri = new Fragment_zameri();
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@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
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);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
FragmentTransaction ftrans = getFragmentManager().beginTransaction();
if (id == R.id.nav_go) {
ftrans.replace(R.id.container, fgo);
} else if (id == R.id.nav_programs) {
ftrans.replace(R.id.container, fprograms);
}else if (id == R.id.nav_uprajnenia) {
ftrans.replace(R.id.container, fuprajnenia);
}else if (id == R.id.nav_statistic) {
ftrans.replace(R.id.container, fstatistic);
} else if (id == R.id.nav_zameri) {
ftrans.replace(R.id.container, fzameri);
} else if (id == R.id.nav_settings) {
ftrans.replace(R.id.container, fsettings);
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}
ftrans.commit();
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}
Fragment_Go 代码:
public class Fragment_Go extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public Fragment_Go() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_Go.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_Go newInstance(String param1, String param2) {
Fragment_Go fragment = new Fragment_Go();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment__go, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
容器标记:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.sharkitt.sportplus.MainActivity"
tools:showIn="@layout/app_bar_main"
android:id="@+id/container">
</FrameLayout>
bottom navigation view
如果它似乎适用于 android 6.0 及更早版本,是否可以在 android 4.2中使用,如果可以,如何使用?
我编写了一个应用程序,显示有关电话运营商、网络类型等的信息。按下按钮后,它崩溃了。下面是程序代码和日志。
public class MainActivity extends AppCompatActivity {
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView)findViewById(R.id.info);
}
public void onSubmit(View v) {
TelephonyManager tm=(TelephonyManager)getSystemService(Context.TELECOM_SERVICE);
int callstate=tm.getCallState();
String callstat="";
switch(callstate){
case TelephonyManager.CALL_STATE_IDLE:
callstat="Call State: Phone is idle\n";
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
callstat="Call State: Phone is in use\n";
break;
case TelephonyManager.CALL_STATE_RINGING:
callstat="Call State: Phone is ringing\n";
break;
}
String opname="\n Operator ID:"+""+tm.getNetworkOperator();
opname=opname+"\n Operator Name:"+""+tm.getNetworkOperatorName();
int phoneType=tm.getPhoneType();
String ptype="";
switch (phoneType){
case TelephonyManager.PHONE_TYPE_CDMA:
ptype="\nPhone Type: CDMA";
break;
case TelephonyManager.PHONE_TYPE_GSM:
ptype="\nPhone Type: GSM";
break;
case TelephonyManager.PHONE_TYPE_SIP:
ptype="\nPhone Type: SIP";
break;
case TelephonyManager.PHONE_TYPE_NONE:
ptype="\nPhone Type: NONE";
break;
}
boolean isRoaming=tm.isNetworkRoaming();
String pDetails="";
if (isRoaming){
pDetails="Roaming : Yes\n";
}
else {
pDetails="Roaming : No\n";
}
tv.setText(callstat+opname+ptype+pDetails);
}
}
日志猫:
5527) 在 java.lang.reflect.Method.invoke(Native Method) 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 在 com.android.internal.os.ZygoteInit.main( ZygoteInit.java:629) 11-12 14:44:42.531 25260-25260/com.galaxy.operator E/MQSEventManagerDelegate: 获取 MQSService 失败。11-12 14:44:42.547 25260-25260/? I/Process:发送信号。PID:25260 SIG:9 739) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 11-12 14:44:42.531 25260-25260/com.galaxy.operator E/MQSEventManagerDelegate: 未能获得 MQSService。11-12 14:44:42.547 25260-25260/? I/Process:发送信号。PID:25260 SIG:9 739) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 11-12 14:44:42.531 25260-25260/com.galaxy.operator E/MQSEventManagerDelegate: 未能获得 MQSService。11-12 14:44:42.547 25260-25260/? I/Process:发送信号。PID:25260 SIG:9
我在清单中提供了以下权限:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
在动画停止 n 次后,广告会显示,但只会触发一次。如何实现每n次重复展示广告。
public void onAnimationEnd(Animation animation) {
if (++counter == 3) {
mInterstitialAd.show();
counter = 0;
}
}
广告代码:
private InterstitialAd mInterstitialAd;
private static int counter=0;
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-9225307158641311/329999999999");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
startAD mobi 拒绝了我的申请,原因如下: StartAD.mobi 横幅必须以与应用程序本地化相同的语言显示(在俄文版应用程序中,横幅必须是俄文,在英文版应用程序中,分别用英语)。在您的应用程序中,当本地化为英语时,会显示俄语横幅。
现在代码如下所示:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// мой id
this.sadView = new SADView(this, "99999999999999999999999");
LinearLayout layout = (LinearLayout)findViewById(R.id.myleaner);
layout.addView(this.sadView);
this.sadView.loadAd(SADView.LANGUAGE_RU);
问题:如何将广告横幅绑定到应用本地化?
实施建议的方法后:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// мой id
this.sadView = new SADView(this, "99999999999999999999");
LinearLayout layout = (LinearLayout) findViewById(R.id.myleaner);
layout.addView(this.sadView);
//this.sadView.loadAd(SADView.LANGUAGE_RU);
public static Locale getSystemLocale(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Resources.getSystem().getConfiguration().getLocales().get(0);
} else {
return Resources.getSystem().getConfiguration().locale;
}
}
switch (getSystemLocale().getLanguage()) {
case "ru":
sadView.loadAd(SADView.LANGUAGE_RU);
break;
case "en":
sadView.loadAd(SADView.LANGUAGE_EN);
break;
}
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// мой id
this.sadView = new SADView(this, "59e49c13e229e670008b4569");
LinearLayout layout = (LinearLayout) findViewById(R.id.myleaner);
layout.addView(this.sadView);
public static Locale getSystemLocale(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Resources.getSystem().getConfiguration().getLocales().get(0);
} else {
return Resources.getSystem().getConfiguration().locale;
}
}
}
switch (getSystemLocale().getLanguage()) {
case "ru":
sadView.loadAd(SADView.LANGUAGE_RU);
break;
case "en":
sadView.loadAd(SADView.LANGUAGE_EN);
break;
}
例如,如何在动画停止后显示一条随机线?目前我已经实现了这样的:
@Override
public void onAnimationEnd(Animation animation) {
//вывод текст здесь
String[] texts = {};
Set<Integer> generated = new HashSet<Integer>();
Random random = new Random ();
int pos = random.nextInt(texts.length);
((TextView) findViewById(R.id.myTextView)).setText(texts[pos]);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
但问题是,一来有String[] texts = {раз, два, ......, тысяча};
一千多个值,二来,我想把所有的东西都存储在字符串中,因为未来计划针对不同语言进行本地化。
@Override
public void onAnimationEnd(Animation animation) {
//вывод текст здесь
Resources res = getResources();
String[] planets = res.getStringArray(R.array.planets_array);
Set<Integer> generated = new HashSet<Integer>();
Random random = new Random ();
int pos = random.nextInt(R.array.planets_array);
((TextView) findViewById(R.id.myTextView)).setText(planets[pos]);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
}
CatLog 输出以下内容:
-09 23:03:08.846 3579-3579/ru.infernal93.butilochka E/AndroidRuntime: FATAL EXCEPTION: main
Process: ru.infernal93.butilochka, PID: 3579
java.lang.ArrayIndexOutOfBoundsException: length=4; index=2122146214
at ru.infernal93.butilochka.ActivityGame$2.onAnimationEnd(ActivityGame.java:81)
at android.view.animation.Animation$3.run(Animation.java:376)
at android.os.Handler.handleCallback(Handler.java:742)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5527)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
10-09 23:03:08.848 3579-3579/ru.infernal93.butilochka E/MQSEventManagerDelegate: failed to get MQSService.
应用程序在设备上正常加载,但在启动后立即崩溃。我尝试了网上已知的所有添加方法,结果都是一样的。
10-07 21:07:08.199 6194-6194/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:09.176 6206-6206/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:22.788 1391-1391/? E/NotificationService: Suppressing notification from package yo.app.free by user request.
10-07 21:07:22.788 1391-1391/? E/NotificationService: Suppressing notification from package yo.app.free by user request.
10-07 21:07:22.861 1391-1391/? E/NotificationService: Suppressing notification from package yo.app.free by user request.
10-07 21:07:27.130 6359-6359/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:27.134 6357-6357/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:28.404 6381-6381/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:29.324 6392-6392/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:31.773 6403-6403/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:32.355 6415-6415/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:32.978 6429-6429/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:33.583 6442-6442/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:34.174 6454-6454/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:34.764 6466-6466/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:35.375 1391-2099/? E/IzatSvc_PassiveLocListener: E/Exiting with error virtual void izat_manager::IzatPassiveLocationListener::onLocationChanged(const izat_manager::IzatLocation*, izat_manager::IzatLocationStatus) line 171 "1"
10-07 21:07:35.412 6478-6478/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:37.536 6491-6491/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:38.149 6502-6502/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:38.820 6513-6513/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:40.163 6524-6524/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:40.450 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.451 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.451 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.452 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.452 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.452 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.453 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.453 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.453 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.454 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.454 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.454 1391-1606/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.483 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.484 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.484 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.484 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.484 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.485 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.485 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.485 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.485 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.486 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.486 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:40.486 3501-3517/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.381 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.381 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.382 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.382 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.382 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.383 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.383 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.384 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.384 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.384 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.385 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:41.385 1391-1524/? E/NativeLibraryHelper: Failed to load assets verifier: 0
10-07 21:07:42.396 713-713/? E/installd: Couldn't opendir /data/app/vmdl1362791904.tmp: No such file or directory
10-07 21:07:42.398 1391-1524/? E/MQSEventManagerDelegate: failed to get MQSService.
10-07 21:07:42.625 2145-2433/? E/Launcher.AllAppsList: Can't load postion for app Бутылочка +
10-07 21:07:42.959 6617-6617/? E/SystemUpdater-LocalAppManager: getDetailAppInfo null: ru.infernal93.butilochka
10-07 21:07:43.042 26823-26823/? E/Finsky: [1] com.google.android.finsky.wear.bl.a(3): onConnectionFailed: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}
10-07 21:07:43.696 6702-6702/? E/HAL: Dawei load: module=/system/lib64/hw/memtrack.msm8953.so
10-07 21:07:43.768 3583-3594/? E/ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only
10-07 21:07:43.894 6790-6790/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_dependencies_apk.apk@classes.dex: Permission denied
10-07 21:07:44.027 6748-6748/? E/ActivityThread: Failed to find provider info for ru.yandex.disk.MetricaContentProvider
10-07 21:07:44.029 6748-6748/? E/ActivityThread: Failed to find provider info for org.stepic.droid.MetricaContentProvider
10-07 21:07:44.031 6748-6748/? E/ActivityThread: Failed to find provider info for com.appmk.book.AOUKZFJHQIIANWBPF.MetricaContentProvider
10-07 21:07:44.033 6748-6748/? E/ActivityThread: Failed to find provider info for ru.hh.android.MetricaContentProvider
10-07 21:07:44.035 6748-6748/? E/ActivityThread: Failed to find provider info for ru.rambler.lenta.MetricaContentProvider
10-07 21:07:44.037 6748-6748/? E/ActivityThread: Failed to find provider info for com.lessons.tree.myapplication.MetricaContentProvider
10-07 21:07:44.107 6748-6748/? E/ActivityThread: Failed to find provider info for ru.habrahabr.MetricaContentProvider
10-07 21:07:44.110 6748-6748/? E/ActivityThread: Failed to find provider info for com.mobilesrepublic.appygeek.MetricaContentProvider
10-07 21:07:44.133 6820-6820/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_slice_0_apk.apk@classes.dex: Permission denied
10-07 21:07:44.181 6827-6827/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_slice_1_apk.apk@classes.dex: Permission denied
10-07 21:07:44.223 6832-6832/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_slice_2_apk.apk@classes.dex: Permission denied
10-07 21:07:44.270 6837-6837/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_slice_3_apk.apk@classes.dex: Permission denied
10-07 21:07:44.317 6840-6840/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_slice_4_apk.apk@classes.dex: Permission denied
10-07 21:07:44.358 6845-6845/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_slice_5_apk.apk@classes.dex: Permission denied
10-07 21:07:44.400 6848-6848/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_slice_6_apk.apk@classes.dex: Permission denied
10-07 21:07:44.441 6851-6851/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_slice_7_apk.apk@classes.dex: Permission denied
10-07 21:07:44.483 6854-6854/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_slice_8_apk.apk@classes.dex: Permission denied
10-07 21:07:44.525 6859-6859/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm64/data@app@ru.infernal93.butilochka-1@split_lib_slice_9_apk.apk@classes.dex: Permission denied
10-07 21:07:44.566 6617-6668/? E/SystemUpdater-DataParser: [AppList] JSON : list is null
No value for miuiApp
10-07 21:07:44.888 6773-6877/ru.infernal93.butilochka E/HAL: Dawei load: module=/system/lib64/hw/gralloc.msm8953.so
10-07 21:07:44.950 6617-6871/? E/SystemUpdater-DataParser: [AppList] JSON : list is null
No value for listApp
10-07 21:07:45.661 6617-6841/? E/SystemUpdater-ConnectionRSA: get key exception : com.android.org.bouncycastle.util.encoders.DecoderException: unable to decode base64 string: invalid characters encountered in base64 data
10-07 21:07:45.685 6617-6841/? E/SystemUpdater-AppActivateStatService: upload app active stat Success!
10-07 21:07:47.828 3583-3594/? E/ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only
10-07 21:07:49.600 6773-7045/ru.infernal93.butilochka E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
10-07 21:08:35.374 1391-2099/? E/IzatSvc_PassiveLocListener: E/Exiting with error virtual void izat_manager::IzatPassiveLocationListener::onLocationChanged(const izat_manager::IzatLocation*, izat_manager::IzatLocationStatus) line 171 "1"
10-07 21:08:42.188 2287-9506/? E/OperatorSimInfo: Create Res Apk Failed
10-07 21:08:42.188 2287-9506/? E/OperatorSimInfo: Create Res Apk Failed
10-07 21:08:42.298 2287-9504/? E/OperatorSimInfo: Create Res Apk Failed
10-07 21:08:42.298 2287-9504/? E/OperatorSimInfo: Create Res Apk Failed
10-07 21:08:42.396 2287-2611/? E/OperatorSimInfo: Create Res Apk Failed
10-07 21:08:42.396 2287-2611/? E/OperatorSimInfo: Create Res Apk Failed
10-07 21:08:42.444 2287-2299/? E/OperatorSimInfo: Create Res Apk Failed
10-07 21:08:42.444 2287-2299/? E/OperatorSimInfo: Create Res Apk Failed
10-07 21:08:44.780 7890-7979/? E/ActivityThread: Failed to find provider info for metok
10-07 21:08:44.864 7890-7985/? E/ActivityThread: Failed to find provider info for metok
10-07 21:08:50.042 7890-7897/? E/System: Uncaught exception thrown by finalizer
10-07 21:08:50.046 7890-7897/? E/System: java.lang.NullPointerException: Attempt to invoke virtual method 'void dalvik.system.CloseGuard.close()' on a null object reference
at java.io.FileInputStream.close(FileInputStream.java:113)
at java.io.FileInputStream.finalize(FileInputStream.java:140)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:229)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:216)
at java.lang.Thread.run(Thread.java:818)
10-07 21:08:57.019 8158-8158/? E/GcmReceiver: Failed to resolve target intent service, skipping classname enforcement
10-07 21:08:57.021 8158-8158/? E/GcmReceiver: Error while delivering the message: ServiceIntent not found.
10-07 21:09:03.855 6684-6717/? E/Crashlytics: Failed to retrieve settings from https://settings.crashlytics.com/spi/v2/platforms/android/apps/ru.hinews/settings
com.crashlytics.android.internal.aD: java.net.SocketTimeoutException: failed to connect to settings.crashlytics.com/54.204.4.24 (port 443) after 10000ms
at com.crashlytics.android.internal.ay.b(SourceFile:1391)
at com.crashlytics.android.internal.ay.f(SourceFile:1664)
at com.crashlytics.android.internal.ay.d(SourceFile:1576)
at com.crashlytics.android.internal.ay.c(SourceFile:1590)
at com.crashlytics.android.internal.aO.a(SourceFile:63)
at com.crashlytics.android.internal.aW.a(SourceFile:48)
at com.crashlytics.android.internal.aW.a(SourceFile:36)
at com.crashlytics.android.internal.aS.c(SourceFile:125)
at com.crashlytics.android.Crashlytics.a(SourceFile:884)
at com.crashlytics.android.Crashlytics.a(SourceFile:54)
at com.crashlytics.android.t.a(SourceFile:839)
at com.crashlytics.android.internal.aa.run(SourceFile:13)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.net.SocketTimeoutException: failed to connect to settings.crashlytics.com/54.204.4.24 (port 443) after 10000ms
at libcore.io.IoBridge.connectErrno(IoBridge.java:169)
at libcore.io.IoBridge.connect(IoBridge.java:122)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:452)
at java.net.Socket.connect(Socket.java:884)
at com.android.okhttp.internal.Platform.connectSocket(Platform.java:117)
at com.android.okhttp.internal.http.SocketConnector.connectRawSocket(SocketConnector.java:160)
at com.android.okhttp.internal.http.SocketConnector.connectTls(SocketConnector.java:79)
at com.android.okhttp.Connection.connect(Connection.java:143)
at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:185)
at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:342)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:331)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:249)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:437)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:388)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaders(HttpURLConnectionImpl.java:150)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:192)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getHeaderField(DelegatingHttpsURLConnection.java:190)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java:25)
at com.crashlytics.android.internal.ay.a(SourceFile:1912)
at com.crashlytics.android.internal.ay.c(SourceFile:1590)
at com.crashlytics.android.internal.aO.a(SourceFile:63)
at com.crashlytics.android.internal.aW.a(SourceFile:48)
at com.crashlytics.android.internal.aW.a(SourceFile:36)
at com.crashlytics.android.internal.aS.c(SourceFile:125)
at com.crashlytics.android.Crashlytics.a(SourceFile:884)
at com.crashlytics.android.Crashlytics.a(SourceFile:54)
at com.crashlytics.android.t.a(SourceFile:839)
at com.crashlytics.android.internal.aa.run(SourceFile:13)
at java.lang.Thread.run(Thread.java:818)
10-07 21:09:35.376 1391-2099/? E/IzatSvc_PassiveLocListener: E/Exiting with error virtual void izat_manager::IzatPassiveLocationListener::onLocationChanged(const izat_manager::IzatLocation*, izat_manager::IzatLocationStatus) line 171 "1"
10-07 21:10:24.220 6684-6718/? E/Crashlytics: Failed to retrieve settings from https://settings.crashlytics.com/spi/v2/platforms/android/apps/ru.hinews/settings
com.crashlytics.android.internal.aD: java.net.SocketTimeoutException: failed to connect to settings.crashlytics.com/174.129.247.236 (port 443) after 10000ms
at com.crashlytics.android.internal.ay.b(SourceFile:1391)
at com.crashlytics.android.internal.ay.f(SourceFile:1664)
at com.crashlytics.android.internal.ay.d(SourceFile:1576)
at com.crashlytics.android.internal.ay.c(SourceFile:1590)
at com.crashlytics.android.internal.aO.a(SourceFile:63)
at com.crashlytics.android.internal.aW.a(SourceFile:48)
at com.crashlytics.android.internal.aW.a(SourceFile:36)
at com.crashlytics.android.internal.aS.c(SourceFile:125)
at com.crashlytics.android.internal.D.a(SourceFile:30)
at com.crashlytics.android.internal.E.a(SourceFile:93)
at com.crashlytics.android.internal.aa.run(SourceFile:13)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.net.SocketTimeoutException: failed to connect to settings.crashlytics.com/174.129.247.236 (port 443) after 10000ms
at libcore.io.IoBridge.connectErrno(IoBridge.java:169)
at libcore.io.IoBridge.connect(IoBridge.java:122)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:452)
at java.net.Socket.connect(Socket.java:884)
at com.android.okhttp.internal.Platform.connectSocket(Platform.java:117)
at com.android.okhttp.internal.http.SocketConnector.connectRawSocket(SocketConnector.java:160)
at com.android.okhttp.internal.http.SocketConnector.connectTls(SocketConnector.java:79)
at com.android.okhttp.Connection.connect(Connection.java:143)
at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:185)
at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:342)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:331)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:249)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:437)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:388)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaders(HttpURLConnectionImpl.java:150)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:192)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getHeaderField(DelegatingHttpsURLConnection.java:190)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java:25)
at com.crashlytics.android.internal.ay.a(SourceFile:1912)
at com.crashlytics.android.internal.ay.c(SourceFile:1590)
at com.crashlytics.android.internal.aO.a(SourceFile:63)
at com.crashlytics.android.internal.aW.a(SourceFile:48)
at com.crashlytics.android.internal.aW.a(SourceFile:36)
at com.crashlytics.android.internal.aS.c(SourceFile:125)
at com.crashlytics.android.internal.D.a(SourceFile:30)
at com.crashlytics.android.internal.E.a(SourceFile:93)
at com.crashlytics.android.internal.aa.run(SourceFile:13)
at java.lang.Thread.run(Thread.java:818)
10-07 21:10:35.377 1391-2099/? E/IzatSvc_PassiveLocListener: E/Exiting with error virtual void izat_manager::IzatPassiveLocationListener::onLocationChanged(const izat_manager::IzatLocation*, izat_manager::IzatLocationStatus) line 171 "1"
10-07 21:10:38.952 1391-1711/? E/WifiHAL: getLowiCallbackTable: requested lowi capabilities: 0x00000004 is not in supported capabilities: 0x00000003. Return NULL.
10-07 21:10:39.618 1391-1711/? E/WifiHAL: getLowiCallbackTable: requested lowi capabilities: 0x00000004 is not in supported capabilities: 0x00000003. Return NULL.
10-07 21:10:39.631 1391-1711/? E/WifiHAL: handleResponse: num Cached results in this fragment:1
10-07 21:10:39.632 1391-1711/? E/WifiHAL: More data: 0, firstScanIdInPatch: 1812, lastProcessedScanId: -1
10-07 21:10:39.632 1391-1711/? E/WifiHAL: gscan_get_cached_results: starting counter: 0
10-07 21:10:39.632 1391-1711/? E/WifiHAL: gscan_get_cached_results: cached_results[0].num_results: 1
10-07 21:10:39.637 1391-1711/? E/WifiHAL: getLowiCallbackTable: requested lowi capabilities: 0x00000004 is not in supported capabilities: 0x00000003. Return NULL.
10-07 21:10:39.682 1391-2883/? E/LocSvc_libulp: E/int ulp_brain_transition_all_providers(), no QUIPC/GNSS transition logic run due to both engines are OFF
10-07 21:11:15.543 1391-1711/? E/WifiHAL: getLowiCallbackTable: requested lowi capabilities: 0x00000004 is not in supported capabilities: 0x00000003. Return NULL.
10-07 21:11:16.204 1391-1711/? E/WifiHAL: getLowiCallbackTable: requested lowi capabilities: 0x00000004 is not in supported capabilities: 0x00000003. Return NULL.
10-07 21:11:16.208 1391-1711/? E/WifiHAL: handleResponse: num Cached results in this fragment:1
10-07 21:11:16.209 1391-1711/? E/WifiHAL: More data: 0, firstScanIdInPatch: 1813, lastProcessedScanId: -1
10-07 21:11:16.209 1391-1711/? E/WifiHAL: gscan_get_cached_results: starting counter: 0
10-07 21:11:16.209 1391-1711/? E/WifiHAL: gscan_get_cached_results: cached_results[0].num_results: 1
10-07 21:11:16.213 1391-1711/? E/WifiHAL: getLowiCallbackTable: requested lowi capabilities: 0x00000004 is not in supported capabilities: 0x00000003. Return NULL.
10-07 21:11:16.239 1391-2883/? E/LocSvc_libulp: E/int ulp_brain_transition_all_providers(), no QUIPC/GNSS transition logic run due to both engines are OFF
10-07 21:11:35.375 1391-2099/? E/IzatSvc_PassiveLocListener: E/Exiting with error virtual void izat_manager::IzatPassiveLocationListener::onLocationChanged(const izat_manager::IzatLocation*, izat_manager::IzatLocationStatus) line 171 "1"
10-07 21:11:53.009 1391-1689/? E/native: do suspend false
10-07 21:11:53.791 11038-11090/? E/AviaryCdsService: LAZY Execution..
10-07 21:12:35.375 1391-2099/? E/IzatSvc_PassiveLocListener: E/Exiting with error virtual void izat_manager::IzatPassiveLocationListener::onLocationChanged(const izat_manager::IzatLocation*, izat_manager::IzatLocationStatus) line 171 "1"
10-07 21:13:35.375 1391-2099/? E/IzatSvc_PassiveLocListener: E/Exiting with error virtual void izat_manager::IzatPassiveLocationListener::onLocationChanged(const izat_manager::IzatLocation*, izat_manager::IzatLocationStatus) line 171 "1"
出于教育目的,我编写了一个小游戏并将其发布在 Play Market 上,并在设置中将其指定为免费。为什么市场说游戏有广告?
链接:https ://play.google.com/store/apps/details?id=en.infernal93.butilochka
动画(瓶子旋转)后如何在屏幕上显示某些文本?我知道您需要分配一个听众,但不需要了解现实中的一切。这是动画代码:
public class ActivityGame extends AppCompatActivity {
public static final Random sRandom = new Random();
private ImageView mBottleImageView;
private int lastAngle = -1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game_activity);
mBottleImageView = (ImageView) findViewById(R.id.imageview_bottle);
mBottleImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
spinBottle();
}
});
}
private void spinBottle() {
int angle = sRandom.nextInt(3500-200)+700;
// Центр вращения
float pivotX = mBottleImageView.getWidth() / 2;
float pivotY = mBottleImageView.getHeight() / 2;
final Animation animation = new RotateAnimation(lastAngle == -1 ? 0 : lastAngle, angle, pivotX, pivotY);
lastAngle = angle;
animation.setDuration(3000);
animation.setFillAfter(true);
mBottleImageView.startAnimation(animation);
}
}