当前位置: 首页>>代码示例>>Java>>正文


Java RingtoneManager.getDefaultUri方法代码示例

本文整理汇总了Java中android.media.RingtoneManager.getDefaultUri方法的典型用法代码示例。如果您正苦于以下问题:Java RingtoneManager.getDefaultUri方法的具体用法?Java RingtoneManager.getDefaultUri怎么用?Java RingtoneManager.getDefaultUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.RingtoneManager的用法示例。


在下文中一共展示了RingtoneManager.getDefaultUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showNotification

import android.media.RingtoneManager; //导入方法依赖的package包/类
private void showNotification(Game game) {
    DateTime dateTime = new DateTime(game.getGameDateTime(), Constants.DATE.VEGAS_TIME_ZONE).plusSeconds(60);
    if (dateTime.isAfterNow()) {
        String ringtonePath = MultiProcessPreference.getDefaultSharedPreferences().getString(mContext.getString(R.string.key_notification_ringtone), null);
        Uri soundUri;
        if (ringtonePath == null) {
            soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        } else {
            soundUri = Uri.parse(ringtonePath);
        }
        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(mContext)
                        .setSmallIcon(R.drawable.ic_league_white_24px)
                        .setContentTitle("Game Started - " + game.getLeagueType().getAcronym())
                        .setContentText(mContext.getString(R.string.team_vs_team_full, game.getFirstTeam().getCity(), game.getSecondTeam().getCity()))
                        .setSound(soundUri);
        // Sets an ID for the notification
        int mNotificationId = createHash(game.getFirstTeam().getCity() + game.getSecondTeam().getCity());
        // Gets an instance of the NotificationManager service
        NotificationManager mNotifyMgr =
                (NotificationManager) mContext.getSystemService(NOTIFICATION_SERVICE);
        // Builds the notification and issues it.
        mNotifyMgr.notify(mNotificationId, mBuilder.build());
    }
}
 
开发者ID:riteshakya037,项目名称:Android-Scrapper,代码行数:26,代码来源:GameUpdateReceiver.java

示例2: sendNotification

import android.media.RingtoneManager; //导入方法依赖的package包/类
/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param messageBody FCM message body received.
 */
private void sendNotification(RemoteMessage.Notification messageBody) {
    System.out.println("SEND NOTIFICATION CALLED");
    Intent intent = new Intent(this, SplashActivity.class);
    System.out.println(messageBody.getBody());
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle(messageBody.getTitle())
            .setContentText(messageBody.getBody())
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
 
开发者ID:rohansapre,项目名称:cleanhood,代码行数:28,代码来源:PushMessagingService.java

示例3: sendNotification

import android.media.RingtoneManager; //导入方法依赖的package包/类
public void sendNotification(String messageBody) {
    Intent intent = new Intent(this, getApplication().getClass());
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 , intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(android.R.drawable.btn_star)
            .setContentTitle(getPackageName())
            .setContentText(messageBody)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
 
开发者ID:marckregio,项目名称:maklib,代码行数:21,代码来源:MakunatFirebaseMessagingService.java

示例4: ringDenAlarm

import android.media.RingtoneManager; //导入方法依赖的package包/类
void ringDenAlarm() {
  // Fix for https://mint.splunk.com/dashboard/project/cd78aa05/errors/2819028090
  //  - undgå at wrappe lydkilde i AlarmLydkilde igen og igen
  if (!(lydkilde instanceof AlarmLydkilde)) {
    Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
    if (alert == null) {
      // alert is null, using backup
      alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
      if (alert == null) {  // I can't see this ever being null (as always have a default notification) but just incase
        // alert backup is null, using 2nd backup
        alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
      }
    }
    lydkilde = new AlarmLydkilde(alert.toString(), lydkilde);
  }
  handler.postDelayed(startAfspilningIntern, 100);
  vibru(4000);
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:19,代码来源:Afspiller.java

示例5: showNotification

import android.media.RingtoneManager; //导入方法依赖的package包/类
public NotificationCompat.Builder showNotification() {

            Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            notificationId = (int) new Date().getTime();
            mNotifyManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
            mBuilder = new NotificationCompat.Builder(getActivity());
            mBuilder.setContentTitle("Sending mail to " + this.company.getCompanyName())
                    .setContentText("Sending...")
                    .setSound(defaultSoundUri)
                    .setSmallIcon(R.drawable.ic_stat_name);

            mBuilder.setProgress(100, 100, true);
            // Displays the progress bar for the first time.
            mNotifyManager.notify(notificationId, mBuilder.build());

            return mBuilder;
        }
 
开发者ID:othreecodes,项目名称:Quicksend,代码行数:18,代码来源:HomeFragment.java

示例6: sendNotification

import android.media.RingtoneManager; //导入方法依赖的package包/类
private void sendNotification(String messageBody) {
    Intent intent = new Intent(this, StartingActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);
    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.bee_logo_app)
            .setContentTitle("Alert")
            .setContentText(messageBody)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);
    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
 
开发者ID:sarikaya,项目名称:Bee-Analyzer,代码行数:18,代码来源:MyFirebaseMessagingService.java

示例7: handleMessage

import android.media.RingtoneManager; //导入方法依赖的package包/类
private void handleMessage(RemoteMessage remoteMessage) {

        Intent intent = new Intent(this, FirebaseAuth.getInstance().getCurrentUser() == null ? LoginActivity.class:MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent intent1 = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);


        Uri defaultURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this,NotificationCompat.CATEGORY_MESSAGE)
                .setSmallIcon(R.drawable.gdg_notification_icon)
                .setContentTitle(remoteMessage.getNotification().getTitle())
                .setContentText(remoteMessage.getNotification().getBody())
                .setAutoCancel(true)
                .setSound(defaultURI)
                .setContentIntent(intent1);

        NotificationManager manager =  ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
        if (manager != null) {
            manager.notify(23,builder.build());
        }


    }
 
开发者ID:coder3101,项目名称:gdgApp,代码行数:25,代码来源:MessagingService.java

示例8: sendNotification

import android.media.RingtoneManager; //导入方法依赖的package包/类
/**
 * Display the notification
 * @param body
 */
public void sendNotification(String body) {

	Intent intent = new Intent(this, MainActivity.class);
	intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

	PendingIntent pendingIntent = PendingIntent.getActivity(this, 0/*Request code*/, intent, PendingIntent.FLAG_ONE_SHOT);
	//Set sound of notification
	Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

	NotificationCompat.Builder notifiBuilder = new NotificationCompat.Builder(this)
		.setSmallIcon(R.mipmap.ic_bloeddonatie_logo_notification)
		.setContentTitle("Bloeddonatie")
		.setContentText(body)
		.setAutoCancel(true)
		.setSound(notificationSound)
		.setContentIntent(pendingIntent);

	NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
	notificationManager.notify(0 /*ID of notification*/, notifiBuilder.build());
}
 
开发者ID:team-htbr,项目名称:1617PROJ1Bloeddonatie-app,代码行数:25,代码来源:MyFirebaseMessagingService.java

示例9: sendNotification

import android.media.RingtoneManager; //导入方法依赖的package包/类
/**
 * Method send notification
 *
 * @param message message object
 */
private void sendNotification(Message message) {
    Intent intent = new Intent(this, ChatActivity.class);
    intent.putExtra("message", message);
    intent.putExtra("id", message.getSender());
    intent.putExtra("name", name);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle("Chat cDa")
            .setContentText(message.getMessage())
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0, notificationBuilder.build());
}
 
开发者ID:codingdojoangola,项目名称:cda-app,代码行数:29,代码来源:FirebaseService.java

示例10: onMessageReceived

import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
public void onMessageReceived(MessageEvent messageEvent) {

    if (messageEvent.getPath().equals("/heart")) {
        final String message = new String(messageEvent.getData());
        Log.v("myTag", "Message path received on watch is: " + messageEvent.getPath());
        Log.v("myTag", "Message received on watch is: " + message);

        // Broadcast message to wearable activity for display
        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("message", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);

        Intent intent2 = new Intent(getApplicationContext(), MainActivity.class);

        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent2,
                PendingIntent.FLAG_ONE_SHOT);

        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);

        NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(getApplicationContext())
                .setAutoCancel(true)   //Automatically delete the notification
                .setSmallIcon(R.drawable.ic_heart_icon) //Notification icon
                .setContentIntent(pendingIntent)
                .setContentTitle("Open upbeat")
                .setContentText("UpBeat to check the pulse")
                .setCategory(Notification.CATEGORY_REMINDER)
                .setPriority(Notification.PRIORITY_HIGH)
                .setSound(defaultSoundUri);


        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getApplicationContext());
        notificationManager.notify(0, notificationBuilder.build());

    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
 
开发者ID:PacktPublishing,项目名称:Android-Wear-Projects,代码行数:41,代码来源:MobileListener.java

示例11: getAlarmUri

import android.media.RingtoneManager; //导入方法依赖的package包/类
private Uri getAlarmUri() {
    Uri alert = RingtoneManager
            .getDefaultUri(RingtoneManager.TYPE_ALARM);
    if (alert == null) {
        alert = RingtoneManager
                .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        if (alert == null) {
            alert = RingtoneManager
                    .getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        }
    }
    return alert;
}
 
开发者ID:akshah1997,项目名称:KJSCE-Hackathon,代码行数:14,代码来源:AlarmReceiver.java

示例12: create

import android.media.RingtoneManager; //导入方法依赖的package包/类
public CustomNotification create(Context context) {
    this.context = context;
    builder = new NotificationCompat.Builder(context);
    builder.setAutoCancel(true);
    builder.setPriority(NotificationCompat.PRIORITY_HIGH);
    builder.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
    Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    builder.setSound(uri);
    return this;
}
 
开发者ID:pedromassango,项目名称:Programmers,代码行数:11,代码来源:CustomNotification.java

示例13: onReceive

import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    //Do some operations, like loading values from a file, and show it in the notification or pass it in the calledActivity
    String loadedString = "This is a string loaded from the Receiver";

    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    //Building our custom Notification
    NotificationCompat.Builder mBuilder =
            (NotificationCompat.Builder) new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.ic_flag) //Set icon
                    .setContentTitle("Notification Title")
                    .setContentText("Click to call calledActivity")
                    .setSound(alarmSound)
                    .setColor(Color.argb(0,21,101,192)) //Color your notification
                    .setVibrate(new long[]{300, 300, 300, 300, 300}) //Vibration intensity
                    .setAutoCancel(true);

    //setting activity called clicking on the notification
    Intent resultIntent = new Intent(context, calledActivity.class);
    resultIntent.putExtra(calledActivity.WORD, loadedString);
    resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    //Building virtual stack, allowing the user to press back to go back to the main activity
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(calledActivity.class);
    stackBuilder.addNextIntent(resultIntent);

    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    mBuilder.setContentIntent(resultPendingIntent);
    notificationManager.notify(MainActivity.notifId, mBuilder.build());
}
 
开发者ID:Cesarsk,项目名称:Android-Notifications-Sample,代码行数:37,代码来源:NotificationReceiver.java

示例14: MyNoti

import android.media.RingtoneManager; //导入方法依赖的package包/类
public MyNoti(Context context) {
    this.context = context;
    title = "True Weather";
    body = "Notification from Shivam";
    icon = R.drawable.main_icon;
    requestCode = (int) System.currentTimeMillis();
    intent = new Intent(context, ShowWeather.class);
    voiceUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
}
 
开发者ID:shivam301296,项目名称:True-Weather,代码行数:10,代码来源:MyNoti.java

示例15: sendNotification

import android.media.RingtoneManager; //导入方法依赖的package包/类
/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param //messageBody FCM message body received.
 */
private void sendNotification(String messageBody, Bitmap image) {
    Log.d("in notifcation","true");
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    //intent.putExtra("AnotherActivity", TrueOrFalse);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    //Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
   // Intent intent = new Intent(this, MainActivity.class);
    //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    //PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
      //      PendingIntent.FLAG_ONE_SHOT);
    Bitmap icon = BitmapFactory.decodeResource(this.getResources(), R.drawable.logo_1_white);

    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    /*NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setLargeIcon(icon)
            .setContentTitle(remotemessage.getFrom())
            .setContentText(remotemessage.getNotification().getBody())
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent)
            .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });*/
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setLargeIcon(icon)/*Notification icon image*/
            .setSmallIcon(R.drawable.logo_1_white)
            .setContentTitle(messageBody)
            .setStyle(new NotificationCompat.BigPictureStyle()
                    .bigPicture(image))/*Notification with Image*/
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent)
            .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });;

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
 
开发者ID:Ronak-59,项目名称:Trinity-App,代码行数:46,代码来源:MyFirebaseMessagingService.java


注:本文中的android.media.RingtoneManager.getDefaultUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。