目前正在尝试使用Android网站培训设施来尝试了解如何为Android构建应用程序。我在“开始第二项活动”方面遇到了问题。发送按钮似乎不起作用,我不知道我做错了什么。我试图通过论坛阅读,因为其他人有问题,但我似乎无法解决我的问题。我已经重新阅读了网站上提供的android教程,但我完成了所示的步骤。我会感激任何帮助和提前感谢。
MainActivity.java:
package com.example.testapp;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends ActionBarActivity {
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@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();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void sendMessage (View view){
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
activity_main.xml中:
<LinearLayout 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"
android:orientation="horizontal" >
<EditText
android:id="@+id/edit_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
DisplayMessageActivity.java
package com.example.testapp;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class DisplayMessageActivity extends ActionBarActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
}
@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();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
的AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<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=".DisplayMessageActivity"
android:label="@string/title_activity_display_message"
android:parentActivityName="com.example.testapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.testapp.MainActivity" />
</activity>
</application>
</manifest>
logcat的:
07-11 19:34:26.244: D/dalvikvm(12926): Debugger has detached; object registry had 1 entries
07-11 19:34:26.684: D/AndroidRuntime(12939): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
07-11 19:34:26.684: D/AndroidRuntime(12939): CheckJNI is OFF
07-11 19:34:26.684: D/AndroidRuntime(12939): setted country_code = UK & IRE
07-11 19:34:26.684: D/AndroidRuntime(12939): setted countryiso_code = GB
07-11 19:34:26.689: D/AndroidRuntime(12939): setted sales_code = BTU
07-11 19:34:26.689: D/AndroidRuntime(12939): readGMSProperty: start
07-11 19:34:26.689: D/AndroidRuntime(12939): readGMSProperty: already setted!!
07-11 19:34:26.689: D/AndroidRuntime(12939): readGMSProperty: end
07-11 19:34:26.689: D/AndroidRuntime(12939): addProductProperty: start
07-11 19:34:26.699: D/dalvikvm(12939): Trying to load lib libjavacore.so 0x0
07-11 19:34:26.699: D/dalvikvm(12939): Added shared lib libjavacore.so 0x0
07-11 19:34:26.709: D/dalvikvm(12939): Trying to load lib libnativehelper.so 0x0
07-11 19:34:26.709: D/dalvikvm(12939): Added shared lib libnativehelper.so 0x0
07-11 19:34:26.824: D/MotionEngine(2240): [@@@ Motion Engine @@@] GetMotionScenarioId -0.028730 0.114922 9.682152 0.000000 0.000000 0.000000 51 20
07-11 19:34:26.879: D/dalvikvm(12939): Note: class Landroid/app/ActivityManagerNative; has 153 unimplemented (abstract) methods
07-11 19:34:26.914: D/AndroidRuntime(12939): Calling main entry com.android.commands.am.Am
07-11 19:34:26.964: I/power(2240): *** acquire_dvfs_lock : lockType : 1 freq : 1000000
07-11 19:34:26.964: D/PowerManagerService(2240): acquireDVFSLockLocked : type : DVFS_MIN_LIMIT frequency : 1000000 uid : 1000 pid : 2240 tag : ActivityManager
07-11 19:34:26.964: W/ActivityManager(2240): mDVFSLock.acquire()
07-11 19:34:26.969: D/Launcher.HomeFragment(24197): onPause
07-11 19:34:26.969: D/widget(24197): [MSC_HERO_Accu_JB]>>> WC:1218 [0:0] fireOP
07-11 19:34:26.969: D/Launcher(24197): onPause, Launcher: 1104847976
07-11 19:34:26.969: D/widget(24197): [MSC_HERO_Accu_JB]>>> WC:1028 [0:0] onPause
07-11 19:34:26.989: D/AndroidRuntime(12939): Shutting down VM
07-11 19:34:26.989: I/AndroidRuntime(12939): NOTE: attach of thread 'Binder_3' failed
07-11 19:34:26.994: D/dalvikvm(12939): GC_CONCURRENT freed 103K, 86% free 600K/4096K, paused 1ms+0ms, total 4ms
07-11 19:34:26.994: D/jdwp(12939): Got wake-up signal, bailing out of select
07-11 19:34:26.994: D/dalvikvm(12939): Debugger has detached; object registry had 1 entries
07-11 19:34:26.994: D/dalvikvm(12950): Late-enabling CheckJNI
07-11 19:34:26.999: D/dalvikvm(1908): WAIT_FOR_CONCURRENT_GC blocked 0ms
07-11 19:34:27.014: E/jdwp(12950): Failed sending reply to debugger: Broken pipe
07-11 19:34:27.014: D/dalvikvm(12950): Debugger has detached; object registry had 1 entries
07-11 19:34:27.014: I/SurfaceFlinger(1907): id=1289(227) createSurf 0x4194b0c4 (1x1),1 flag=400, uestapp
07-11 19:34:27.014: I/SurfaceFlinger(1907): SurfaceFlinger : eMagnificationFactorChanged. magnificationFactor=1.0
07-11 19:34:27.014: I/SurfaceFlinger(1907): SurfaceFlinger : eZoomPositionChanged. zoomX=0.0 zoomY=0.0
07-11 19:34:27.014: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.029: D/dalvikvm(1908): GC_EXPLICIT freed 39K, 7% free 12110K/12931K, paused 12ms+1ms, total 31ms
07-11 19:34:27.029: D/dalvikvm(1908): WAIT_FOR_CONCURRENT_GC blocked 0ms
07-11 19:34:27.029: V/WindowManager(2240): rotationForOrientationLw(orient=-1, last=0); user=0 USER_ROTATION_LOCKED mLidState=-1 mDockMode=0 mHdmiPlugged=false mAccelerometerDefault=false sensorRotation=-1
07-11 19:34:27.044: D/WindowManager(2240): PhoneWindowManager: focusChangedLw
07-11 19:34:27.044: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.044: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.044: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.049: D/MotionEngine(2240): [@@@ Motion Engine @@@] MOVE Recognition ############ 40
07-11 19:34:27.049: D/dalvikvm(1908): GC_EXPLICIT freed <1K, 7% free 12110K/12931K, paused 3ms+2ms, total 23ms
07-11 19:34:27.049: D/dalvikvm(1908): WAIT_FOR_CONCURRENT_GC blocked 0ms
07-11 19:34:27.069: D/Launcher(24197): onTrimMemory. Level: 20
07-11 19:34:27.074: D/dalvikvm(1908): GC_EXPLICIT freed <1K, 7% free 12110K/12931K, paused 2ms+2ms, total 23ms
07-11 19:34:27.074: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.079: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.084: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.084: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.104: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.104: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.104: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.104: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.104: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.104: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.119: D/dalvikvm(2240): GC_CONCURRENT freed 1598K, 56% free 24570K/55111K, paused 18ms+18ms, total 148ms
07-11 19:34:27.139: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.139: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.139: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.174: D/WindowManager(2240): mInputFocus is not null.
07-11 19:34:27.204: I/SurfaceFlinger(1907): id=1290(1) createSurf 0x4111a4b4 (1x1),1 flag=400, NainActivit
07-11 19:34:27.204: I/SurfaceFlinger(1907): SurfaceFlinger : eMagnificationFactorChanged. magnificationFactor=1.0
07-11 19:34:27.204: I/SurfaceFlinger(1907): SurfaceFlinger : eZoomPositionChanged. zoomX=0.0 zoomY=0.0
07-11 19:34:27.204: D/WindowManager(2240): PhoneWindowManager: focusChangedLw
07-11 19:34:27.204: D/STATUSBAR-StatusBarManagerService(2240): setSystemUiVisibility(0x0)
07-11 19:34:27.204: D/STATUSBAR-StatusBarManagerService(2240): manageDisableList what=0x0 pkg=WindowManager.LayoutParams
07-11 19:34:27.209: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.219: D/libEGL(12950): loaded /system/lib/egl/libEGL_mali.so
07-11 19:34:27.219: D/libEGL(12950): loaded /system/lib/egl/libGLESv1_CM_mali.so
07-11 19:34:27.219: D/libEGL(12950): loaded /system/lib/egl/libGLESv2_mali.so
07-11 19:34:27.224: D/(12950): Device driver API match
07-11 19:34:27.224: D/(12950): Device driver API version: 10
07-11 19:34:27.224: D/(12950): User space API version: 10
07-11 19:34:27.224: D/(12950): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16 15:37:13 KST 2012
07-11 19:34:27.254: D/OpenGLRenderer(12950): Enabling debug mode 0
07-11 19:34:27.269: I/ClipboardServiceEx(2240): Send intent for dismiss clipboard dialog inside hideCurrentInputLocked() !
07-11 19:34:27.314: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.329: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.334: D/Launcher.HomeFragment(24197): onStop
07-11 19:34:27.334: D/Launcher(24197): onStop, Launcher: 1104847976
07-11 19:34:27.334: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.429: I/power(2240): *** release_dvfs_lock : lockType : 1
07-11 19:34:27.429: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.429: I/SurfaceFlinger(1907): id=1287 Removed Mauncher idx=1 MapSz=6
07-11 19:34:27.429: I/SurfaceFlinger(1907): id=1287 Removed Mauncher idx=-2 MapSz=6
07-11 19:34:27.429: D/PowerManagerService(2240): releaseDVFSLockLocked : all DVFS_MIN_LIMIT are released
07-11 19:34:27.429: W/ActivityManager(2240): mDVFSLock.release()
07-11 19:34:27.529: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.529: I/SurfaceFlinger(1907): id=1289 Removed uestapp idx=3 MapSz=5
07-11 19:34:27.534: I/SurfaceFlinger(1907): id=1289 Removed uestapp idx=-2 MapSz=5
07-11 19:34:27.534: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.539: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:27.874: D/MotionEngine(2240): [@@@ Motion Engine @@@] GetMotionScenarioId -0.028730 0.047884 9.768343 0.000000 0.000000 0.000000 51 20
07-11 19:34:28.924: D/MotionEngine(2240): [@@@ Motion Engine @@@] GetMotionScenarioId -0.047884 0.067038 9.653421 0.000000 0.000000 0.000000 51 20
07-11 19:34:29.369: D/MotionEngine(2240): [@@@ Motion Engine @@@] MOVE Recognition ############ 40
07-11 19:34:29.974: D/MotionEngine(2240): [@@@ Motion Engine @@@] GetMotionScenarioId -0.009577 0.134075 9.758766 0.000000 0.000000 0.000000 51 20
07-11 19:34:30.299: I/InputReader(2240): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.1652 ]
07-11 19:34:30.299: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:30.299: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:30.299: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:30.299: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:30.299: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:30.349: I/InputReader(2240): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]
07-11 19:34:30.349: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x1
07-11 19:34:30.349: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x1
07-11 19:34:30.349: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x1
07-11 19:34:30.424: D/KJH(2643): [KeyboardView-init] mGuestureTraceKeyboardGapForXt9_9 : 0
07-11 19:34:30.454: D/ApplicationPolicy(2240): isStatusBarNotificationAllowed: packageName = android
07-11 19:34:30.454: D/ApplicationPolicy(2240): isStatusBarNotificationAllowed: packageName = android
07-11 19:34:30.454: D/PhoneStatusBar(2514): addNotification score=0
07-11 19:34:30.454: D/STATUSBAR-NotificationService(2240): Noti Alert - mSystemReady:true, AlertEnabled:true
07-11 19:34:30.454: D/PowerManagerService(2240): mIsSipVisible : true
07-11 19:34:30.454: D/STATUSBAR-NotificationService(2240): Noti Alert - mSystemReady:true, AlertEnabled:true
07-11 19:34:30.459: I/SurfaceFlinger(1907): id=1291(271) createSurf 0x41950f14 (720x531),1 flag=0, JnputMethod
07-11 19:34:30.459: I/SurfaceFlinger(1907): SurfaceFlinger : eMagnificationFactorChanged. magnificationFactor=1.0
07-11 19:34:30.459: I/SurfaceFlinger(1907): SurfaceFlinger : eZoomPositionChanged. zoomX=0.0 zoomY=0.0
07-11 19:34:30.459: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:30.464: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:30.469: D/StatusBar(2514): expanding top notification at 4entry.userCollapsed() = false
07-11 19:34:30.474: D/StatusBar(2514): expanding top notification at 4entry.userCollapsed() = false
07-11 19:34:30.519: D/dalvikvm(2643): GC_FOR_ALLOC freed 2347K, 27% free 16774K/22855K, paused 28ms, total 28ms
07-11 19:34:30.579: W/SignalStrength(2240): getGsmLevel=4
07-11 19:34:30.579: W/SignalStrength(2240): getLevel=4 (SignalStrength: 14 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 gsm|lte 4)
07-11 19:34:30.579: W/SignalStrength(2514): getGsmLevel=4
07-11 19:34:30.579: W/SignalStrength(2514): getLevel=4 (SignalStrength: 14 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 gsm|lte 4)
07-11 19:34:30.579: W/SignalStrength(2514): getGsmLevel=4
07-11 19:34:30.579: W/SignalStrength(2514): getLevel=4 (SignalStrength: 14 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 gsm|lte 4)
07-11 19:34:30.579: W/SignalStrength(2240): getGsmDbm=-85
07-11 19:34:30.579: W/SignalStrength(2240): getDbm=-85
07-11 19:34:30.579: W/SignalStrength(2240): getGsmAsuLevel=14
07-11 19:34:30.579: W/SignalStrength(2240): getAsuLevel=14
07-11 19:34:30.579: D/STATUSBAR-NetworkController(2514): onSignalStrengthsChanged signalStrength=SignalStrength: 14 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 gsm|lte 4 level=4
07-11 19:34:30.589: D/dalvikvm(2643): GC_CONCURRENT freed 281K, 22% free 18046K/22855K, paused 11ms+2ms, total 30ms
07-11 19:34:30.589: D/dalvikvm(2643): WAIT_FOR_CONCURRENT_GC blocked 14ms
07-11 19:34:30.614: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:30.849: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:30.849: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:31.029: D/MotionEngine(2240): [@@@ Motion Engine @@@] GetMotionScenarioId -0.019154 0.143652 9.921572 0.000000 0.000000 0.000000 51 20
07-11 19:34:31.034: I/InputReader(2240): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.1653 ]
07-11 19:34:31.034: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:31.034: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:31.034: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:31.034: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:31.034: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:31.039: E/AudioPolicyService(1910): getOutput() tid 1910 ++
07-11 19:34:31.039: E/AudioPolicyService(1910): getOutput() tid 1910 --
07-11 19:34:31.039: V/AudioPolicyManagerBase(1910): getOutput() stream 1, samplingRate 0, format 0, channelMask 3, flags 0
07-11 19:34:31.039: V/AudioPolicyManagerBase(1910): getOutputsForDevice device 0002 -> 0002
07-11 19:34:31.039: V/AudioPolicyManagerBase(1910): getOutput() returns output 2
07-11 19:34:31.039: E/AudioPolicyService(1910): getOutput() tid 2199 ++
07-11 19:34:31.039: E/AudioPolicyService(1910): getOutput() tid 2199 --
07-11 19:34:31.039: V/AudioPolicyManagerBase(1910): getOutput() stream 1, samplingRate 0, format 0, channelMask 3, flags 0
07-11 19:34:31.039: V/AudioPolicyManagerBase(1910): getOutputsForDevice device 0002 -> 0002
07-11 19:34:31.039: V/AudioPolicyManagerBase(1910): getOutput() returns output 2
07-11 19:34:31.039: E/AudioPolicyService(1910): getOutput() tid 7156 ++
07-11 19:34:31.039: E/AudioPolicyService(1910): getOutput() tid 7156 --
07-11 19:34:31.039: V/AudioPolicyManagerBase(1910): getOutput() stream 1, samplingRate 44100, format 1, channelMask 3, flags 4
07-11 19:34:31.039: V/AudioPolicyManagerBase(1910): getOutputsForDevice device 0002 -> 0002
07-11 19:34:31.039: V/AudioPolicyManagerBase(1910): getOutput() returns output 2
07-11 19:34:31.044: V/LvOutput(1910): initCheck: 0
07-11 19:34:31.044: V/LvOutput(1910): attachEffects: attach processing to output 2, stream 1, session 2235, mode 0
07-11 19:34:31.044: V/LvOutput(1910): attachEffects: no output processing needs to be attached to this stream
07-11 19:34:31.044: V/LvOutput(1910): LvOutput::setAllProcessorEnabled(false) mOutputs.size(0)
07-11 19:34:31.044: V/AudioPolicyManagerBase(1910): startOutput() output 2, stream 1, session 2235
07-11 19:34:31.044: V/AudioPolicyManagerBase(1910): changeRefCount() stream 1, count 1
07-11 19:34:31.044: V/AudioPolicyManagerBase(1910): getNewDevice() selected device 2
07-11 19:34:31.044: V/AudioPolicyManagerBase(1910): setOutputDevice() output 2 device 0002 force 0 delayMs 0
07-11 19:34:31.044: V/AudioPolicyManagerBase(1910): setOutputDevice() prevDevice 0002
07-11 19:34:31.044: V/AudioPolicyManagerBase(1910): setOutputDevice() setting same device 0002 or null device for output 2
07-11 19:34:31.044: V/AudioPolicyManagerBase(1910): releaseOutput() 2
07-11 19:34:31.044: I/AudioMixer(1910): setParameter(TRACK, FORMAT, 0x1)
07-11 19:34:31.044: E/AudioMixer(1910): MOON > checkSEC_PCM ++ 1
07-11 19:34:31.044: I/AudioHardwareTinyALSA(1910): AudioStreamOutALSA::write setDevice
07-11 19:34:31.044: D/AudioHardwareTinyALSA(1910): OutALSA::setDevice: mode = 0, newDevice=0x2, currentDevice=0x2 ,force= 0
07-11 19:34:31.044: D/AudioHardwareTinyALSA(1910): OutALSA::setDevice: mDevice 0x2, newDevice = 0x2
07-11 19:34:31.044: D/AudioHardwareTinyALSA(1910): setOutputVolume
07-11 19:34:31.044: D/TinyUCM(1910): setModifier Normal, en=1
07-11 19:34:31.044: I/AudioHardwareTinyALSA(1910): OutALSA::setDevice: mHandle NULL mode[0], Device[00000002]
07-11 19:34:31.044: I/AudioHardwareTinyALSA(1910): Open: mDefaults->direction=0 device=0
07-11 19:34:31.044: D/AudioHardwareTinyALSA(1910): Channel: 2, Samplerate: 44100, Format: 0, Peroid Size: 1024, Period Count: 4
07-11 19:34:31.044: I/AudioHardwareTinyALSA(1910): before pcm_prepare
07-11 19:34:31.044: D/AudioHardwareTinyALSA(1910): setPcmInterface: Stream=0x1, iSamplerate=8000++
07-11 19:34:31.044: D/AudioHardwareTinyALSA(1910): setPcmInterface--
07-11 19:34:31.089: I/SurfaceFlinger(1907): id=1292(272) createSurf 0x41950f74 (1x1),1 flag=0, QopupWindow
07-11 19:34:31.094: I/SurfaceFlinger(1907): SurfaceFlinger : eMagnificationFactorChanged. magnificationFactor=1.0
07-11 19:34:31.094: I/SurfaceFlinger(1907): SurfaceFlinger : eZoomPositionChanged. zoomX=0.0 zoomY=0.0
07-11 19:34:31.094: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:31.114: I/InputReader(2240): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]
07-11 19:34:31.114: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x1
07-11 19:34:31.114: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x1
07-11 19:34:31.114: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x1
07-11 19:34:31.114: V/LvOutput(1910): initCheck: 0
07-11 19:34:31.114: V/LvOutput(1910): detachEffects: detach processing for output 2, stream 1, session 2235
07-11 19:34:31.114: V/LvOutput(1910): detachEffects: no output processing was attached to this stream
07-11 19:34:31.114: V/AudioPolicyManagerBase(1910): stopOutput() output 2, stream 1, session 2235
07-11 19:34:31.114: V/AudioPolicyManagerBase(1910): changeRefCount() stream 1, count 0
07-11 19:34:31.119: V/AudioPolicyManagerBase(1910): getNewDevice() selected device 0
07-11 19:34:31.119: V/AudioPolicyManagerBase(1910): setOutputDevice() output 2 device 0000 force 0 delayMs 184
07-11 19:34:31.119: V/AudioPolicyManagerBase(1910): setOutputDevice() prevDevice 0002
07-11 19:34:31.119: V/AudioPolicyManagerBase(1910): setOutputDevice() setting same device 0000 or null device for output 2
07-11 19:34:31.169: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:31.199: I/SurfaceFlinger(1907): id=1292 Removed QopupWindow idx=4 MapSz=6
07-11 19:34:31.199: D/KeyguardViewMediator(2240): setHidden false
07-11 19:34:31.199: I/SurfaceFlinger(1907): id=1292 Removed QopupWindow idx=-2 MapSz=6
07-11 19:34:31.204: I/InputReader(2240): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.1654 ]
07-11 19:34:31.204: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:31.204: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:31.204: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:31.204: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:31.204: I/InputDispatcher(2240): Delivering touch to current input target: action: 0x0
07-11 19:34:31.209: E/AudioPolicyService(1910): getOutput() tid 2199 ++
07-11 19:34:31.209: E/AudioPolicyService(1910): getOutput() tid 2199 --
07-11 19:34:31.209: V/AudioPolicyManagerBase(1910): getOutput() stream 1, samplingRate
答案 0 :(得分:0)
我认为在创建Intent对象时,必须这样做:
Intent intent = new Intent(MainActivity.this, DisplayMessageActivity.class);
因为在这种情况下,您可能正在获取View的上下文,而不是活动的上下文。 如果它不起作用,请粘贴您的logcat控制台,然后我们就可以看到您遇到的错误。
答案 1 :(得分:0)
在DisplayMessageActivity
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
LinearLayout linear = new LinearLayout(this);
linear.setOrientation(LinearLayout.HORIZONTAL);
linear.addView(textView);
//set the text view as the activity layout
setContentView(linear);